Handles mouseover events for the menu.
(event: MouseEvent)
| 228 | |
| 229 | /** Handles mouseover events for the menu. */ |
| 230 | onMouseOver(event: MouseEvent) { |
| 231 | if (!this.visible()) { |
| 232 | return; |
| 233 | } |
| 234 | |
| 235 | this.hasBeenHovered.set(true); |
| 236 | const item = this.inputs.items().find(i => i.element()?.contains(_getEventTarget(event))); |
| 237 | |
| 238 | if (!item) { |
| 239 | return; |
| 240 | } |
| 241 | |
| 242 | const parent = this.inputs.parent(); |
| 243 | const activeItem = this.inputs.activeItem(); |
| 244 | |
| 245 | if (parent instanceof MenuItemPattern) { |
| 246 | const grandparent = parent.inputs.parent(); |
| 247 | if (grandparent instanceof MenuPattern) { |
| 248 | grandparent._clearTimeouts(); |
| 249 | grandparent.listBehavior.goto(parent, {focusElement: false}); |
| 250 | } |
| 251 | } |
| 252 | |
| 253 | if (activeItem && activeItem !== item) { |
| 254 | this._closeItem(activeItem); |
| 255 | } |
| 256 | |
| 257 | if (item.expanded()) { |
| 258 | this._clearCloseTimeout(); |
| 259 | } |
| 260 | |
| 261 | this._openItem(item); |
| 262 | this.listBehavior.goto(item, {focusElement: this.shouldFocus()}); |
| 263 | } |
| 264 | |
| 265 | /** Closes the specified menu item after a delay. */ |
| 266 | private _closeItem(item: MenuItemPattern<V>) { |
no test coverage detected