0
0
Fork 0

Fix reply button on media modal not giving focus to compose form (#17626)

* Avoid compose form and modal management fighting for focus

* Fix reply button on media modal footer not giving focus to compose form
This commit is contained in:
Claire 2022-02-25 00:51:01 +01:00 committed by GitHub
parent d4592bbfcd
commit 2cd31b3177
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 50 additions and 19 deletions

View file

@ -18,6 +18,7 @@ export default class ModalRoot extends React.PureComponent {
g: PropTypes.number,
b: PropTypes.number,
}),
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);