Merge pull request #418 from orangemug/fix/modal-exit-apply-changes

Delay modal close until blur events have triggered
This commit is contained in:
Orange Mug 2018-10-22 16:32:39 +01:00 committed by GitHub
commit b0c877d4ae
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -19,6 +19,17 @@ class Modal extends React.Component {
underlayClickExits: true
}
// See <https://github.com/maputnik/editor/issues/416>
onClose = () => {
if (document.activeElement) {
document.activeElement.blur();
}
setImmediate(() => {
this.props.onOpenToggle(false);
});
}
getApplicationNode() {
return document.getElementById('app');
}
@ -32,7 +43,7 @@ class Modal extends React.Component {
getApplicationNode={this.getApplicationNode}
data-wd-key={this.props["data-wd-key"]}
verticallyCenter={true}
onExit={() => this.props.onOpenToggle(false)}
onExit={this.onClose}
>
<div className="maputnik-modal"
data-wd-key={this.props["data-wd-key"]}
@ -41,7 +52,7 @@ class Modal extends React.Component {
<h1 className="maputnik-modal-header-title">{this.props.title}</h1>
<span className="maputnik-modal-header-space"></span>
<button className="maputnik-modal-header-toggle"
onClick={() => this.props.onOpenToggle(false)}
onClick={this.onClose}
data-wd-key={this.props["data-wd-key"]+".close-modal"}
>
<MdClose />