Delay modal close until blur events have triggered.

This commit is contained in:
orangemug 2018-10-19 08:39:07 +01:00
parent 906d7ac3d5
commit 218ce148d5

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 />