DEV: follow-up to avoid using schedule when opening modal from dropdown (#27970)

This commit is contained in:
Kris 2024-07-18 10:33:06 -04:00 committed by GitHub
parent 6344e3f937
commit 9719aa0e2d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 15 additions and 13 deletions

View File

@ -3,7 +3,6 @@ import { tracked } from "@glimmer/tracking";
import { getOwner } from "@ember/application"; import { getOwner } from "@ember/application";
import { hash } from "@ember/helper"; import { hash } from "@ember/helper";
import { action } from "@ember/object"; import { action } from "@ember/object";
import { schedule } from "@ember/runloop";
import { service } from "@ember/service"; import { service } from "@ember/service";
import { modifier as modifierFn } from "ember-modifier"; import { modifier as modifierFn } from "ember-modifier";
import { and, eq, not, or } from "truth-helpers"; import { and, eq, not, or } from "truth-helpers";
@ -92,7 +91,12 @@ export default class GlimmerHeader extends Component {
return; 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(); this.closeCurrentMenu();
} }
}; };
@ -110,7 +114,6 @@ export default class GlimmerHeader extends Component {
@action @action
closeCurrentMenu() { closeCurrentMenu() {
schedule("afterRender", () => {
if (this.search.visible) { if (this.search.visible) {
this.toggleSearchMenu(); this.toggleSearchMenu();
} else if (this.header.userVisible) { } else if (this.header.userVisible) {
@ -120,7 +123,6 @@ export default class GlimmerHeader extends Component {
this.toggleHamburger(); this.toggleHamburger();
document.getElementById(HAMBURGER_BUTTON_ID)?.focus(); document.getElementById(HAMBURGER_BUTTON_ID)?.focus();
} }
});
} }
@action @action