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

@ -163,8 +163,13 @@ class ComposeForm extends ImmutablePureComponent {
selectionStart = selectionEnd;
}
this.autosuggestTextarea.textarea.setSelectionRange(selectionStart, selectionEnd);
this.autosuggestTextarea.textarea.focus();
// Because of the wicg-inert polyfill, the activeElement may not be
// 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.autosuggestTextarea.textarea.setSelectionRange(selectionStart, selectionEnd);
this.autosuggestTextarea.textarea.focus();
}).catch(console.error);
} else if(prevProps.isSubmitting && !this.props.isSubmitting) {
this.autosuggestTextarea.textarea.focus();
} else if (this.props.spoiler !== prevProps.spoiler) {