[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

@ -246,9 +246,14 @@ class ComposeForm extends ImmutablePureComponent {
selectionStart = selectionEnd = text.length;
}
if (textarea) {
textarea.setSelectionRange(selectionStart, selectionEnd);
textarea.focus();
if (!singleColumn) textarea.scrollIntoView();
// 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(() => {
textarea.setSelectionRange(selectionStart, selectionEnd);
textarea.focus();
if (!singleColumn) textarea.scrollIntoView();
}).catch(console.error);
}
// Refocuses the textarea after submitting.