Skip to content

Commit 2c7e47e

Browse files
committed
v0.0.8 build
1 parent 15e3adc commit 2c7e47e

File tree

3 files changed

+17
-15
lines changed

3 files changed

+17
-15
lines changed

lib/SLDSModal/index.js

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -62,14 +62,16 @@ module.exports = _react2['default'].createClass({
6262

6363
getInitialState: function getInitialState() {
6464
return {
65-
isOpen: this.props.isOpen,
65+
isClosing: false,
6666
revealed: false
6767
};
6868
},
6969

7070
componentDidMount: function componentDidMount() {
7171
var _this = this;
7272

73+
console.log('!!! window.activeElement !!! ', document.activeElement);
74+
this.setState({ returnFocusTo: document.activeElement });
7375
if (!this.state.revealed) {
7476
setTimeout(function () {
7577
_this.setState({ revealed: true });
@@ -78,12 +80,14 @@ module.exports = _react2['default'].createClass({
7880
this.updateBodyScroll();
7981
},
8082

81-
openModal: function openModal() {
82-
this.setState({ isOpen: true });
83-
},
84-
8583
closeModal: function closeModal() {
86-
this.setState({ isOpen: false });
84+
this.setState({ isClosing: true });
85+
if (this.state.returnFocusTo && this.state.returnFocusTo.focus) {
86+
this.state.returnFocusTo.focus();
87+
}
88+
if (this.props.onRequestClose) {
89+
this.props.onRequestClose();
90+
}
8791
},
8892

8993
handleSubmitModal: function handleSubmitModal() {
@@ -92,7 +96,7 @@ module.exports = _react2['default'].createClass({
9296

9397
updateBodyScroll: function updateBodyScroll() {
9498
if (window && document && document.body) {
95-
if (this.state.isOpen) {
99+
if (!this.state.isClosing) {
96100
document.body.style.overflow = 'hidden';
97101
} else {
98102
document.body.style.overflow = 'inherit';
@@ -147,7 +151,7 @@ module.exports = _react2['default'].createClass({
147151
return _react2['default'].createElement(
148152
_reactModal2['default'],
149153
{
150-
isOpen: this.state.isOpen,
154+
isOpen: this.props.isOpen,
151155
onRequestClose: this.closeModal,
152156
style: customStyles,
153157
overlayClassName: 'slds-modal-backdrop' + (this.state.revealed ? ' slds-modal-backdrop--open' : '') },
@@ -157,14 +161,13 @@ module.exports = _react2['default'].createClass({
157161

158162
componentDidUpdate: function componentDidUpdate(prevProps, prevState) {
159163

160-
if (this.state.isOpen !== prevState.isOpen) {
164+
if (this.state.isClosing !== prevState.isClosing) {
161165

162166
this.updateBodyScroll();
163167

164-
if (!this.state.isOpen) {
165-
if (this.props.returnFocusTo && this.props.returnFocusTo.focus) {
166-
this.props.returnFocusTo.focus();
167-
}
168+
if (this.state.isClosing) {
169+
console.log('CLOSING: ');
170+
168171
if (this.isMounted()) {
169172
var el = this.getDOMNode().parentNode;
170173
if (el && el.getAttribute('data-slds-modal')) {

lib/SLDSModal/trigger.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ var SLDSModalTrigger = {
3131
{
3232
title: cfg.title,
3333
footer: cfg.footer,
34-
returnFocusTo: cfg.returnFocusTo,
3534
isOpen: true },
3635
cfg.content
3736
);

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "design-system-react",
3-
"version": "0.0.7",
3+
"version": "0.0.8",
44
"description": "Salesforce Lightning Design System React components",
55
"scripts": {
66
"start": "node server.js",

0 commit comments

Comments
 (0)