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