diff options
author | Thibaut Girka <thib@sitedethib.com> | 2018-12-21 18:40:50 +0100 |
---|---|---|
committer | ThibG <thib@sitedethib.com> | 2018-12-21 20:00:49 +0100 |
commit | 1a3088364fe602bb48647d78dda440b174424e17 (patch) | |
tree | e9459e1aaa07e630a6ace41a26a1ccc07bfcd49c /app/javascript/flavours | |
parent | 0605c004a54640cd1511558e5ded15958174223c (diff) |
Fix composer not getting focus after reply confirmation dialog
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/flavours')
-rw-r--r-- | app/javascript/flavours/glitch/components/modal_root.js | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/app/javascript/flavours/glitch/components/modal_root.js b/app/javascript/flavours/glitch/components/modal_root.js index cc26f6a11..7a90e6b8a 100644 --- a/app/javascript/flavours/glitch/components/modal_root.js +++ b/app/javascript/flavours/glitch/components/modal_root.js @@ -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) { |