Skip to content

Commit 7379b7f

Browse files
committed
modal progress
1 parent 18e0fed commit 7379b7f

File tree

5 files changed

+30
-30
lines changed

5 files changed

+30
-30
lines changed

components/SLDSModal/index.jsx

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@ module.exports = React.createClass( {
5757
},
5858

5959
componentDidMount () {
60+
console.log('!!! window.activeElement !!! ',document.activeElement);
61+
this.setState({returnFocusTo:document.activeElement})
6062
if(!this.state.revealed){
6163
setTimeout(()=>{
6264
this.setState({revealed:true});
@@ -65,9 +67,14 @@ module.exports = React.createClass( {
6567
this.updateBodyScroll();
6668
},
6769

68-
6970
closeModal () {
7071
this.setState({isClosing: true});
72+
if(this.state.returnFocusTo && this.state.returnFocusTo.focus){
73+
this.state.returnFocusTo.focus();
74+
}
75+
if(this.props.onRequestClose){
76+
this.props.onRequestClose();
77+
}
7178
},
7279

7380
handleSubmitModal () {
@@ -131,9 +138,8 @@ module.exports = React.createClass( {
131138

132139

133140
if(this.state.isClosing){
134-
if(this.props.returnFocusTo && this.props.returnFocusTo.focus){
135-
this.props.returnFocusTo.focus();
136-
}
141+
console.log('CLOSING: ');
142+
137143
if(this.isMounted()){
138144
const el = this.getDOMNode().parentNode;
139145
if(el && el.getAttribute('data-slds-modal')){

components/SLDSModal/trigger.jsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ const SLDSModalTrigger = {
2121
const comp = <SLDSModal
2222
title={cfg.title}
2323
footer={cfg.footer}
24-
returnFocusTo={cfg.returnFocusTo}
2524
isOpen={true}>
2625
{cfg.content}
2726
</SLDSModal>

demo/pages/HomePage/ModalSection.jsx

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ module.exports = React.createClass( {
5757
},
5858

5959
handleOpenModalClick (event) {
60-
SLDSModalTrigger.open(this.getModalConfig(event.target));
60+
SLDSModalTrigger.open(this.getModalConfig());
6161
},
6262

6363
openModal () {
@@ -124,7 +124,7 @@ module.exports = React.createClass( {
124124
</div>;
125125
},
126126

127-
getModalConfig (returnFocusToElement) {
127+
getModalConfig () {
128128
return ({
129129
title:<span>Super Stuff</span>,
130130
content: <div>
@@ -135,8 +135,7 @@ module.exports = React.createClass( {
135135
footer:[
136136
<button className='slds-button slds-button--neutral' onClick={this.closeModal}>Cancel</button>,
137137
<button className='slds-button slds-button--neutral slds-button--brand' onClick={this.handleSubmitModal}>Save</button>
138-
],
139-
returnFocusTo: returnFocusToElement
138+
]
140139
});
141140
},
142141

demo/pages/HomePage/ModalSection2.jsx

Lines changed: 14 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ module.exports = React.createClass( {
6262

6363
openModal () {
6464
this.setState({modalIsOpen: true});
65-
SLDSModalTrigger.open(this.getModalConfig());
65+
// SLDSModalTrigger.open(this.getModalConfig());
6666
},
6767

6868
closeModal () {
@@ -73,10 +73,6 @@ module.exports = React.createClass( {
7373
this.closeModal();
7474
},
7575

76-
handleModalCancel () {
77-
console.log('!!! handleModalCancel !!!');
78-
},
79-
8076
getModalContent () {
8177
return <div>
8278
<p>Sit nulla est ex deserunt exercitation anim occaecat. Nostrud ullamco deserunt aute id consequat veniam incididunt duis in sint irure nisi. Mollit officia cillum Lorem ullamco minim nostrud elit officia tempor esse quis. Cillum sunt ad dolore
@@ -127,20 +123,18 @@ module.exports = React.createClass( {
127123
</div>;
128124
},
129125

130-
getModalConfig (returnFocusToElement) {
131-
return ({
132-
title:<span>Super Stuff</span>,
133-
content: <div>
134-
{this.getModalContent()}
135-
136126

137-
</div>,
138-
footer:[
139-
<button className='slds-button slds-button--neutral' onClick={this.handleModalCancel}>Cancel</button>,
140-
<button className='slds-button slds-button--neutral slds-button--brand' onClick={this.handleSubmitModal}>Save</button>
141-
],
142-
returnFocusTo: returnFocusToElement
143-
});
127+
renderModal () {
128+
return <SLDSModal
129+
isOpen={this.state.modalIsOpen}
130+
title={<span>Super Stuff</span>}
131+
footer={[
132+
<button className='slds-button slds-button--neutral' onClick={this.closeModal}>Cancel</button>,
133+
<button className='slds-button slds-button--neutral slds-button--brand' onClick={this.handleSubmitModal}>Save</button>
134+
]}
135+
onRequestClose={this.closeModal}>
136+
{this.getModalContent()}
137+
</SLDSModal>;
144138
},
145139

146140
render() {
@@ -159,11 +153,10 @@ module.exports = React.createClass( {
159153
*/}
160154

161155
<div className='slds-p-vertical--large'>
162-
<SLDSButton flavor='brand' onClick={this.handleOpenModalClick}>
156+
<SLDSButton flavor='brand' onClick={this.openModal}>
163157
Open Modal
164158
</SLDSButton>
165-
166-
159+
{this.renderModal()}
167160
</div>
168161
</div>
169162

demo/pages/HomePage/index.jsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import {ButtonIcon, Icon} from "./../../../components/SLDSIcons";
1717
import ButtonSection from './ButtonSection';
1818
import PicklistBaseSection from './PicklistBaseSection';
1919
import ModalSection from './ModalSection';
20+
import ModalSection2 from './ModalSection2';
2021
import DatePickerSingleSelectSection from './DatePickerSingleSelectSection';
2122
import LookupBaseSection from './LookupBaseSection';
2223

@@ -64,6 +65,8 @@ module.exports = React.createClass( {
6465

6566
<PicklistBaseSection />
6667

68+
<ModalSection2 />
69+
6770
<ModalSection />
6871

6972
<DatePickerSingleSelectSection />

0 commit comments

Comments
 (0)