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