DEV: follow-up to avoid using schedule when opening modal from dropdown (#27970)
This commit is contained in:
parent
6344e3f937
commit
9719aa0e2d
|
@ -3,7 +3,6 @@ import { tracked } from "@glimmer/tracking";
|
|||
import { getOwner } from "@ember/application";
|
||||
import { hash } from "@ember/helper";
|
||||
import { action } from "@ember/object";
|
||||
import { schedule } from "@ember/runloop";
|
||||
import { service } from "@ember/service";
|
||||
import { modifier as modifierFn } from "ember-modifier";
|
||||
import { and, eq, not, or } from "truth-helpers";
|
||||
|
@ -92,7 +91,12 @@ export default class GlimmerHeader extends Component {
|
|||
return;
|
||||
}
|
||||
|
||||
if (!panelBody.contains(event.relatedTarget)) {
|
||||
// don't remove focus from newly opened modal
|
||||
const isFocusInModal = document
|
||||
.querySelector(".d-modal")
|
||||
?.contains(event.relatedTarget);
|
||||
|
||||
if (!panelBody.contains(event.relatedTarget) && !isFocusInModal) {
|
||||
this.closeCurrentMenu();
|
||||
}
|
||||
};
|
||||
|
@ -110,17 +114,15 @@ export default class GlimmerHeader extends Component {
|
|||
|
||||
@action
|
||||
closeCurrentMenu() {
|
||||
schedule("afterRender", () => {
|
||||
if (this.search.visible) {
|
||||
this.toggleSearchMenu();
|
||||
} else if (this.header.userVisible) {
|
||||
this.toggleUserMenu();
|
||||
document.getElementById(USER_BUTTON_ID)?.focus();
|
||||
} else if (this.header.hamburgerVisible) {
|
||||
this.toggleHamburger();
|
||||
document.getElementById(HAMBURGER_BUTTON_ID)?.focus();
|
||||
}
|
||||
});
|
||||
if (this.search.visible) {
|
||||
this.toggleSearchMenu();
|
||||
} else if (this.header.userVisible) {
|
||||
this.toggleUserMenu();
|
||||
document.getElementById(USER_BUTTON_ID)?.focus();
|
||||
} else if (this.header.hamburgerVisible) {
|
||||
this.toggleHamburger();
|
||||
document.getElementById(HAMBURGER_BUTTON_ID)?.focus();
|
||||
}
|
||||
}
|
||||
|
||||
@action
|
||||
|
|
Loading…
Reference in New Issue