mirror of
https://github.com/discourse/discourse.git
synced 2025-01-31 22:52:59 +08:00
FIX: Properly close search menu on click/touch outside (#25000)
This commit is contained in:
parent
ed20800986
commit
c91d053dec
|
@ -67,8 +67,17 @@ export default class SearchMenu extends Component {
|
||||||
|
|
||||||
@bind
|
@bind
|
||||||
onDocumentPress(event) {
|
onDocumentPress(event) {
|
||||||
if (!event.target.closest(".search-menu-container.menu-panel-results")) {
|
// If the search menu header button is clicked, we don't need to do anything and can
|
||||||
this.menuPanelOpen = false;
|
// let the header handle cleanup. Otherwise we mess with the toggling of the popup.
|
||||||
|
if (event.target.closest(".header-dropdown-toggle.search-dropdown")) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (
|
||||||
|
this.menuPanelOpen &&
|
||||||
|
!event.target.closest(".search-menu .search-menu-container")
|
||||||
|
) {
|
||||||
|
this.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -106,7 +115,7 @@ export default class SearchMenu extends Component {
|
||||||
|
|
||||||
// We want to blur the active element (search input) when in stand-alone mode
|
// We want to blur the active element (search input) when in stand-alone mode
|
||||||
// so that when we focus on the search input again, the menu panel pops up
|
// so that when we focus on the search input again, the menu panel pops up
|
||||||
document.activeElement.blur();
|
document.getElementById(SEARCH_INPUT_ID)?.blur();
|
||||||
this.menuPanelOpen = false;
|
this.menuPanelOpen = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user