diff --git a/addons/web/static/src/search/control_panel/control_panel.js b/addons/web/static/src/search/control_panel/control_panel.js index 8d9e26ca18b..a316254b0bc 100644 --- a/addons/web/static/src/search/control_panel/control_panel.js +++ b/addons/web/static/src/search/control_panel/control_panel.js @@ -74,15 +74,15 @@ export class ControlPanel extends Component { this.mainButtons = useRef("mainButtons"); useEffect(() => { - if (!this.env.isSmall) { - return; - } // on small screen, clean-up the dropdown elements - const dropdownButtons = this.mainButtons.el.querySelectorAll(".dropdown-menu button"); + const dropdownButtons = this.mainButtons.el.querySelectorAll(".o_control_panel_collapsed_create.dropdown-menu button"); if (!dropdownButtons.length) { this.mainButtons.el - .querySelectorAll(".dropdown-menu, .dropdown-toggle") + .querySelectorAll(".o_control_panel_collapsed_create.dropdown-menu, .o_control_panel_collapsed_create.dropdown-toggle") .forEach((el) => el.classList.add("d-none")); + this.mainButtons.el + .querySelectorAll(".o_control_panel_collapsed_create.btn-group") + .forEach((el) => el.classList.remove("btn-group")); return; } for (const button of dropdownButtons) { diff --git a/addons/web/static/src/search/control_panel/control_panel.xml b/addons/web/static/src/search/control_panel/control_panel.xml index 1d8a10416dd..312e54780f9 100644 --- a/addons/web/static/src/search/control_panel/control_panel.xml +++ b/addons/web/static/src/search/control_panel/control_panel.xml @@ -3,26 +3,24 @@
-
-
-
- -
- - - -
-
- +
+
+
+
+ + + +
+
- +
@@ -36,41 +34,36 @@
-
+
-
- - @@ -120,7 +113,7 @@
-
+
diff --git a/addons/web/static/src/search/search_bar/search_bar.js b/addons/web/static/src/search/search_bar/search_bar.js index f5d5fae2ca6..3e61f330912 100644 --- a/addons/web/static/src/search/search_bar/search_bar.js +++ b/addons/web/static/src/search/search_bar/search_bar.js @@ -9,6 +9,9 @@ import { DomainSelectorDialog } from "@web/core/domain_selector_dialog/domain_se import { fuzzyTest } from "@web/core/utils/search"; import { _t } from "@web/core/l10n/translation"; import { SearchBarMenu } from "../search_bar_menu/search_bar_menu"; +import { useDebounced } from "@web/core/utils/timing"; +import { browser } from "@web/core/browser/browser"; +import { SIZES } from "@web/core/ui/ui_service"; import { Component, @@ -31,13 +34,14 @@ export class SearchBar extends Component { this.fields = this.env.searchModel.searchViewFields; this.searchItemsFields = this.env.searchModel.getSearchItems((f) => f.type === "field"); this.root = useRef("root"); + this.ui = useService("ui"); // core state this.state = useState({ expanded: [], focusedIndex: 0, query: "", - showSearchBar: !this.env.isSmall, + showSearchBar: this.ui.size > SIZES.SM, }); // derived state @@ -60,6 +64,10 @@ export class SearchBar extends Component { useExternalListener(window, "click", this.onWindowClick); useExternalListener(window, "keydown", this.onWindowKeydown); + + this.onResize = useDebounced(this.onResize, 200); + onMounted(() => browser.addEventListener("resize", this.onResize)); + onWillUnmount(() => browser.removeEventListener("resize", this.onResize)); } /** @@ -435,6 +443,10 @@ export class SearchBar extends Component { this.inputRef.el.focus(); } + onResize() { + this.state.showSearchBar = this.ui.size > SIZES.SM; + } + /** * @param {KeyboardEvent} ev */ diff --git a/addons/web/static/src/search/search_bar/search_bar.xml b/addons/web/static/src/search/search_bar/search_bar.xml index 2e8fa11aea7..8bed86d6193 100644 --- a/addons/web/static/src/search/search_bar/search_bar.xml +++ b/addons/web/static/src/search/search_bar/search_bar.xml @@ -97,8 +97,8 @@
- -