diff --git a/addons/web/static/src/core/debug/debug_menu.xml b/addons/web/static/src/core/debug/debug_menu.xml index fd69e987256..a65e02ea73d 100644 --- a/addons/web/static/src/core/debug/debug_menu.xml +++ b/addons/web/static/src/core/debug/debug_menu.xml @@ -12,7 +12,7 @@ diff --git a/addons/web/static/src/core/debug/profiling/profiling_item.xml b/addons/web/static/src/core/debug/profiling/profiling_item.xml index 940f18131cc..d8c64358da1 100644 --- a/addons/web/static/src/core/debug/profiling/profiling_item.xml +++ b/addons/web/static/src/core/debug/profiling/profiling_item.xml @@ -2,7 +2,7 @@ - +
diff --git a/addons/web/static/src/core/dropdown/dropdown.js b/addons/web/static/src/core/dropdown/dropdown.js index 27cfd76efea..455006d2e04 100644 --- a/addons/web/static/src/core/dropdown/dropdown.js +++ b/addons/web/static/src/core/dropdown/dropdown.js @@ -3,7 +3,6 @@ import { useBus, useEffect, useService } from "@web/core/utils/hooks"; import { usePosition } from "../position/position_hook"; import { useDropdownNavigation } from "./dropdown_navigation_hook"; -import { ParentClosingMode } from "./dropdown_item"; import { localization } from "../l10n/localization"; const { Component, core, hooks, useState, QWeb } = owl; @@ -17,6 +16,8 @@ const DIRECTION_CARET_CLASS = { right: "dropright", }; +export const DROPDOWN = Symbol("Dropdown"); + /** * @typedef DropdownState * @property {boolean} open @@ -66,8 +67,18 @@ export class Dropdown extends Component { ); // Set up nested dropdowns --------------------------------------------- - this.hasParentDropdown = this.env.inDropdown; - useSubEnv({ inDropdown: true }); + this.parentDropdown = this.env[DROPDOWN]; + useSubEnv({ + [DROPDOWN]: { + close: this.close.bind(this), + closeAllParents: () => { + this.close(); + if (this.parentDropdown) { + this.parentDropdown.closeAllParents(); + } + }, + }, + }); // Set up key navigation ----------------------------------------------- useDropdownNavigation(); @@ -75,7 +86,7 @@ export class Dropdown extends Component { // Set up toggler and positioning -------------------------------------- /** @type {string} **/ let position = - this.props.position || (this.hasParentDropdown ? "right-start" : "bottom-start"); + this.props.position || (this.parentDropdown ? "right-start" : "bottom-start"); let [direction, variant = "middle"] = position.split("-"); if (localization.direction === "rtl") { if (["bottom", "top"].includes(direction)) { @@ -180,25 +191,6 @@ export class Dropdown extends Component { // Handlers // ------------------------------------------------------------------------- - /** - * Checks if should close on dropdown item selection. - * - * @param {CustomEvent} ev - */ - onItemSelected(ev) { - // Handle parent closing request - const { dropdownClosingRequest } = ev.detail; - const closeAll = dropdownClosingRequest.mode === ParentClosingMode.AllParents; - const closeSelf = - dropdownClosingRequest.isFresh && - dropdownClosingRequest.mode === ParentClosingMode.ClosestParent; - if (!this.props.manualOnly && (closeAll || closeSelf)) { - this.close(); - } - // Mark closing request as started - ev.detail.dropdownClosingRequest.isFresh = false; - } - /** * Dropdowns react to each other state changes through this method. * diff --git a/addons/web/static/src/core/dropdown/dropdown.xml b/addons/web/static/src/core/dropdown/dropdown.xml index cfd9e111e44..d0a98d9d2ec 100644 --- a/addons/web/static/src/core/dropdown/dropdown.xml +++ b/addons/web/static/src/core/dropdown/dropdown.xml @@ -4,14 +4,13 @@