]> cat aescling's git repositories - mastodon.git/commitdiff
Fix composer not getting focus after reply confirmation dialog
authorThibaut Girka <thib@sitedethib.com>
Fri, 21 Dec 2018 17:40:50 +0000 (18:40 +0100)
committerThibG <thib@sitedethib.com>
Fri, 21 Dec 2018 19:00:49 +0000 (20:00 +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/flavours/glitch/components/modal_root.js

index cc26f6a1127f7785beb9955827f249437744edc9..7a90e6b8a41cc4b8900fbf694f8964b40f8a8785 100644 (file)
@@ -39,13 +39,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;
       this.handleModalClose();
     }
     if (this.props.children) {