mirror of
https://github.com/discourse/discourse.git
synced 2024-11-22 05:59:39 +08:00
FIX: attempts to make autofocus more resilient in modals (#10680)
The current situation could cause a transition on the button to end after/during modal has shown and causing the button to get focus again. Browsers would then refuse to switch focus. This is a kinda convulted solution, but it's a general purpose solution which doesn't involve changing anything in plugins/themes or core templates.
This commit is contained in:
parent
32d6286bea
commit
4af48f7998
|
@ -1,3 +1,4 @@
|
|||
import afterTransition from "discourse/lib/after-transition";
|
||||
import I18n from "I18n";
|
||||
import { next } from "@ember/runloop";
|
||||
import { on } from "discourse-common/utils/decorators";
|
||||
|
@ -116,5 +117,15 @@ export default Component.extend({
|
|||
} else {
|
||||
this.set("dismissable", true);
|
||||
}
|
||||
|
||||
if (this.element) {
|
||||
const autofocusInputs = this.element.querySelectorAll(
|
||||
".modal-body input[autofocus]"
|
||||
);
|
||||
|
||||
if (autofocusInputs.length) {
|
||||
afterTransition(() => autofocusInputs[0].focus());
|
||||
}
|
||||
}
|
||||
},
|
||||
});
|
||||
|
|
|
@ -26,8 +26,6 @@ export default Controller.extend(ModalFunctionality, {
|
|||
element
|
||||
.closest(".modal-inner-container")
|
||||
.addEventListener("mousedown", this.mouseDown);
|
||||
|
||||
document.activeElement.blur();
|
||||
});
|
||||
},
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user