about summary refs log tree commit diff
path: root/app/javascript
diff options
context:
space:
mode:
authorThibG <thib@sitedethib.com>2018-12-21 18:52:41 +0100
committerEugen Rochko <eugen@zeonfederated.com>2018-12-21 18:52:41 +0100
commita6079a42b66a7cfab4b5ef5ba72b020fe98b5d54 (patch)
treec42942ebb6af508b1c0757d3355c17742429ae29 /app/javascript
parentde3cecf37a1d6865063c88b2eae5431625a296b2 (diff)
Fix composer not getting focus after reply confirmation dialog (#9602)
The modal-handling code gives back focus to the element focused when the
modal opened. However, in the case of reply confirmation, it would do so
*after* the composer code itself requested focus.
Diffstat (limited to 'app/javascript')
-rw-r--r--app/javascript/mastodon/components/modal_root.js6
1 files changed, 4 insertions, 2 deletions
diff --git a/app/javascript/mastodon/components/modal_root.js b/app/javascript/mastodon/components/modal_root.js
index 114f74937..ef1156571 100644
--- a/app/javascript/mastodon/components/modal_root.js
+++ b/app/javascript/mastodon/components/modal_root.js
@@ -33,13 +33,15 @@ export default class ModalRoot extends React.PureComponent {
     } else if (!nextProps.children) {
       this.setState({ revealed: false });
     }
+    if (!nextProps.children && !!this.props.children) {
+      this.activeElement.focus();
+      this.activeElement = null;
+    }
   }
 
   componentDidUpdate (prevProps) {
     if (!this.props.children && !!prevProps.children) {
       this.getSiblings().forEach(sibling => sibling.removeAttribute('inert'));
-      this.activeElement.focus();
-      this.activeElement = null;
     }
     if (this.props.children) {
       requestAnimationFrame(() => {