* Close the open menu if the current active item opened the requested MenuStackItem. * @param menu The menu requested to be closed. * @param options Options to configure the behavior on close. * - `focusParentTrigger` Whether to focus the parent trigger after closing the menu.
(menu: MenuStackItem, options?: {focusParentTrigger?: boolean})
| 165 | * - `focusParentTrigger` Whether to focus the parent trigger after closing the menu. |
| 166 | */ |
| 167 | protected closeOpenMenu(menu: MenuStackItem, options?: {focusParentTrigger?: boolean}) { |
| 168 | const {focusParentTrigger} = {...options}; |
| 169 | const keyManager = this.keyManager; |
| 170 | const trigger = this.triggerItem; |
| 171 | if (menu === trigger?.getMenuTrigger()?.getMenu()) { |
| 172 | trigger?.getMenuTrigger()?.close(); |
| 173 | // If the user has moused over a sibling item we want to focus the element under mouse focus |
| 174 | // not the trigger which previously opened the now closed menu. |
| 175 | if (focusParentTrigger) { |
| 176 | if (trigger) { |
| 177 | keyManager.setActiveItem(trigger); |
| 178 | } else { |
| 179 | keyManager.setFirstItemActive(); |
| 180 | } |
| 181 | } |
| 182 | } |
| 183 | } |
| 184 | |
| 185 | /** Sets up the subscription that keeps the items list in sync. */ |
| 186 | private _setItems() { |
nothing calls this directly
no test coverage detected