webmail: don't switch back focus after autocompleting address

actually, this fix can reduce focus changes for more operations. withStatus is
often used to show an operation in progress in the status bar, only when the
operation isn't done within 1 second. we would restore focus to the element
before the operation started. that was done because we disable elements
sometimes (preventing duplicate form submission). for things like the
autocomplete, with the tab key, which also moves focus to the next element, we
don't want that focus switched back again.
This commit is contained in:
Mechiel Lukkien 2024-03-05 08:46:56 +01:00
parent 63c3c1fd6a
commit 79f91ebd87
No known key found for this signature in database
2 changed files with 2 additions and 2 deletions

View file

@ -1967,7 +1967,7 @@ const withStatus = async (action, promise, disablable, noAlert) => {
if (disablable) {
disablable.disabled = false;
}
if (origFocus && document.activeElement !== origFocus && origFocus instanceof HTMLElement) {
if (disablable && origFocus && document.activeElement !== origFocus && origFocus instanceof HTMLElement && origFocus.parentNode) {
origFocus.focus();
}
if (id) {

View file

@ -902,7 +902,7 @@ const withStatus = async <T>(action: string, promise: Promise<T>, disablable?: D
if (disablable) {
disablable.disabled = false
}
if (origFocus && document.activeElement !== origFocus && origFocus instanceof HTMLElement) {
if (disablable && origFocus && document.activeElement !== origFocus && origFocus instanceof HTMLElement && origFocus.parentNode) {
origFocus.focus()
}
if (id) {