diff --git a/app/assets/javascripts/discourse/app/components/header.gjs b/app/assets/javascripts/discourse/app/components/header.gjs index 6a589d73fdce2..7470b635e6de4 100644 --- a/app/assets/javascripts/discourse/app/components/header.gjs +++ b/app/assets/javascripts/discourse/app/components/header.gjs @@ -10,7 +10,7 @@ import PluginOutlet from "discourse/components/plugin-outlet"; import DAG from "discourse/lib/dag"; import scrollLock from "discourse/lib/scroll-lock"; import { scrollTop } from "discourse/lib/scroll-top"; -import delayedDestroy from "discourse/modifiers/delayed-destroy"; +import DiscourseURL from "discourse/lib/url"; import AuthButtons from "./header/auth-buttons"; import Contents from "./header/contents"; import HamburgerDropdownWrapper from "./header/hamburger-dropdown-wrapper"; @@ -48,7 +48,7 @@ export default class GlimmerHeader extends Component { @service appEvents; @service header; - @tracked hasClosingAnimation = false; + @tracked skipSearchContext = this.site.mobileView; appEventsListeners = modifierFn(() => { this.appEvents.on( @@ -112,13 +112,6 @@ export default class GlimmerHeader extends Component { }; }); - @action - handleAnimationComplete() { - this.hasClosingAnimation = false; - this.search.visible = false; - this.toggleBodyScrolling(false); - } - @action closeCurrentMenu() { if (this.search.visible) { @@ -160,23 +153,23 @@ export default class GlimmerHeader extends Component { @action toggleSearchMenu() { - if ( - this.site.mobileView && - this.router.currentRouteName === "full-page-search" - ) { - scrollTop(); - document.querySelector(".full-page-search").focus(); - return false; - } + if (this.site.mobileView) { + const context = this.search.searchContext; + let params = ""; + if (context) { + params = `?context=${context.type}&context_id=${context.id}&skip_context=${this.skipSearchContext}`; + } - if (this.site.mobileView && this.search.visible) { - // hide is delayed for the duration of `search-slide-out` animation - this.hasClosingAnimation = true; - } else { - this.search.visible = !this.search.visible; - this.toggleBodyScrolling(true); + if (this.router.currentRouteName === "full-page-search") { + scrollTop(); + document.querySelector(".full-page-search").focus(); + return false; + } else { + return DiscourseURL.routeTo("/search" + params); + } } + this.search.visible = !this.search.visible; if (!this.search.visible) { this.search.highlightTerm = ""; this.search.inTopicContext = false; @@ -303,13 +296,8 @@ export default class GlimmerHeader extends Component { {{#if this.search.visible}} {{else if this.header.hamburgerVisible}}
diff --git a/app/assets/javascripts/discourse/app/components/search-menu-panel.gjs b/app/assets/javascripts/discourse/app/components/search-menu-panel.gjs index 71b70c4f968c0..28a2fa2c02493 100644 --- a/app/assets/javascripts/discourse/app/components/search-menu-panel.gjs +++ b/app/assets/javascripts/discourse/app/components/search-menu-panel.gjs @@ -2,10 +2,8 @@ import Component from "@glimmer/component"; import { service } from "@ember/service"; import MenuPanel from "discourse/components/menu-panel"; import SearchMenu from "discourse/components/search-menu"; -import concatClass from "discourse/helpers/concat-class"; export default class SearchMenuPanel extends Component { - @service search; @service site; get animationClass() { @@ -17,10 +15,7 @@ export default class SearchMenuPanel extends Component {