]> cat aescling's git repositories - mastodon.git/commitdiff
Fix composer not getting focus after reply confirmation dialog (#9602)
authorThibG <thib@sitedethib.com>
Fri, 21 Dec 2018 17:52:41 +0000 (18:52 +0100)
committerEugen Rochko <eugen@zeonfederated.com>
Fri, 21 Dec 2018 17:52:41 +0000 (18:52 +0100)
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.

app/javascript/mastodon/components/modal_root.js

index 114f74937d281cb5e8c0d2b01dcea5127a1aa017..ef1156571f149fe38235fe9711b1cf7776b413a4 100644 (file)
@@ -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(() => {