Opened 5 years ago

Closed 5 years ago

Last modified 4 years ago

#9384 closed bug (fixed)

Menu: _focus function forgets null check with doing a pattern match on event.type

Reported by: darkdev Owned by:
Priority: minor Milestone: 1.10.4
Component: ui.menu Version: 1.10.3
Keywords: Cc:
Blocked by: Blocking:

Description

Sorry to report as a bug instead of just fixing myself, but i have to run and wouldn't want to modify without running all the unit tests.

ISSUE: ui.menu widget's focus function forgets null check with doing a pattern match on event.type. The UI Menu API documentation even gives the menu("focus",...) example passing null as the event argument. And focus gets triggered from a variety of other cases, which means that due to this other events aren't able to be called as suggested in the API docs.

Browser: Chrome Noticed in ui 1.10.2 (line 11774), found to still be present in 1.10.3 (line 11790) problematic code:

if ( nested.length && ( /mouse/.test( event.type ) ) ) {

this._startOpening(nested);

}

correction suggestion:

if ( nested.length && event && ( /mouse/.test( event.type ) ) ) {

this._startOpening(nested);

}

I have already found a work around, which is to always pass the supposedly optional event argument. But it's not ideal. here is my working code, without eventObj argument it fails, i am just prototyping for now, but i will be using this with non-mouse events to position a menu where the mouse is.

var menuHolder = $(menuHTML).appendTo($("body")).menu(menuOptions); menuHolder.menu("next", eventObj); menuHolder.menu("expand", eventObj); bind the events for disposing of the context menu

$("body").find("*").not($("button#testContextMenu, .ContextMenuHolder, .ContextMenuHolder *")).mousedown(closeContextMenu);

Change History (4)

comment:1 Changed 5 years ago by TJ VanToll

Resolution: fixed
Status: newclosed

Menu: Ensure an event was passed before checking its type. Fixes #9384 - Menu: _focus function forgets null check with doing a pattern match on event.type

Changeset: 670f650b99103bcea779f8ad0428e05cb7e37053

comment:2 Changed 5 years ago by tj.vantoll

Milestone: none1.11.0

comment:3 Changed 4 years ago by TJ VanToll

Menu: Ensure an event was passed before checking its type. Fixes #9384 - Menu: _focus function forgets null check with doing a pattern match on event.type (cherry picked from commit 670f650b99103bcea779f8ad0428e05cb7e37053)

Changeset: 9b398520c5e1a313d0c1ebfa7dfd892f8b3e440c

comment:4 Changed 4 years ago by Scott González

Milestone: 1.11.01.10.4
Note: See TracTickets for help on using tickets.