Skip to content

Commit

Permalink
v0.0.8 build
Browse files Browse the repository at this point in the history
  • Loading branch information
ivansfdc committed Oct 1, 2015
1 parent 15e3adc commit 2c7e47e
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 15 deletions.
29 changes: 16 additions & 13 deletions lib/SLDSModal/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,16 @@ module.exports = _react2['default'].createClass({

getInitialState: function getInitialState() {
return {
isOpen: this.props.isOpen,
isClosing: false,
revealed: false
};
},

componentDidMount: function componentDidMount() {
var _this = this;

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

openModal: function openModal() {
this.setState({ isOpen: true });
},

closeModal: function closeModal() {
this.setState({ isOpen: false });
this.setState({ isClosing: true });
if (this.state.returnFocusTo && this.state.returnFocusTo.focus) {
this.state.returnFocusTo.focus();
}
if (this.props.onRequestClose) {
this.props.onRequestClose();
}
},

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

updateBodyScroll: function updateBodyScroll() {
if (window && document && document.body) {
if (this.state.isOpen) {
if (!this.state.isClosing) {
document.body.style.overflow = 'hidden';
} else {
document.body.style.overflow = 'inherit';
Expand Down Expand Up @@ -147,7 +151,7 @@ module.exports = _react2['default'].createClass({
return _react2['default'].createElement(
_reactModal2['default'],
{
isOpen: this.state.isOpen,
isOpen: this.props.isOpen,
onRequestClose: this.closeModal,
style: customStyles,
overlayClassName: 'slds-modal-backdrop' + (this.state.revealed ? ' slds-modal-backdrop--open' : '') },
Expand All @@ -157,14 +161,13 @@ module.exports = _react2['default'].createClass({

componentDidUpdate: function componentDidUpdate(prevProps, prevState) {

if (this.state.isOpen !== prevState.isOpen) {
if (this.state.isClosing !== prevState.isClosing) {

this.updateBodyScroll();

if (!this.state.isOpen) {
if (this.props.returnFocusTo && this.props.returnFocusTo.focus) {
this.props.returnFocusTo.focus();
}
if (this.state.isClosing) {
console.log('CLOSING: ');

if (this.isMounted()) {
var el = this.getDOMNode().parentNode;
if (el && el.getAttribute('data-slds-modal')) {
Expand Down
1 change: 0 additions & 1 deletion lib/SLDSModal/trigger.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ var SLDSModalTrigger = {
{
title: cfg.title,
footer: cfg.footer,
returnFocusTo: cfg.returnFocusTo,
isOpen: true },
cfg.content
);
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "design-system-react",
"version": "0.0.7",
"version": "0.0.8",
"description": "Salesforce Lightning Design System React components",
"scripts": {
"start": "node server.js",
Expand Down

0 comments on commit 2c7e47e

Please sign in to comment.