0
0
Fork 0

[Glitch] Fix reply button on media modal not giving focus to compose form

Port 2cd31b3177 to glitch-soc

Signed-off-by: Claire <claire.github-309c@sitedethib.com>
This commit is contained in:
Claire 2022-02-25 00:51:01 +01:00
parent 2e2b8a9a40
commit 8e04ba87b7
7 changed files with 51 additions and 20 deletions

View file

@ -18,6 +18,7 @@ export default class ModalRoot extends React.PureComponent {
b: PropTypes.number,
}),
noEsc: PropTypes.bool,
ignoreFocus: PropTypes.bool,
};
activeElement = this.props.children ? document.activeElement : null;
@ -72,7 +73,9 @@ export default class ModalRoot extends React.PureComponent {
// immediately selectable, we have to wait for observers to run, as
// described in https://github.com/WICG/inert#performance-and-gotchas
Promise.resolve().then(() => {
this.activeElement.focus({ preventScroll: true });
if (!this.props.ignoreFocus) {
this.activeElement.focus({ preventScroll: true });
}
this.activeElement = null;
}).catch(console.error);