Opened 9 years ago

Closed 9 years ago

#16784 closed defect (fixed)

[regression] exception in MenuBase

Reported by: Douglas Hays Owned by: bill
Priority: high Milestone: 1.9
Component: Dijit Version: 1.9.0a2
Keywords: Cc:
Blocked By: Blocking:


Load test_Menu.html (I'm testing on Chrome).
Click File, then click Save (everything seems OK).
Click File again, and again click Save (exception is thrown about focusNode being null).
This worked OK in 1.8.

Change History (4)

comment:1 Changed 9 years ago by Douglas Hays

Milestone: tbd1.9
Priority: undecidedhigh

comment:2 Changed 9 years ago by bill

Good catch. Started in [30082].

comment:3 Changed 9 years ago by bill

When the menu is closed, MenuBar tries to restore focus to the previously focused MenuBarItem (the one labeled "File"). It uses this.focusedChild which, unsurprisingly is null, since there is no focused child.

In more detail:

  • user clicks on "File", which sets MenuBar.focusedChild to the "File" MenuBarItem
  • the drop down menu opens, but this doesn't set this.focusedChild to null (although it probably should), because there's no _onBlur() event since focus has moved to a child of the MenuBar
  • when the menu closes, focus is returned to the "File" MenuBar item, and this code in MenuBase sets focusedChild to null, even though the MenuBar is in fact focused:
// Repeat what _KeyNavContainer.onBlur() does, so that the MenuBar gets treated as blurred even though the user
// hasn't clicked or focused anywhere outside of the MenuBar yet.  Otherwise, the Menu code gets confused since
// the menu is in a passive state but this.focusedChild is still set.
domAttr.set(this.domNode, "tabIndex", this.tabIndex);
	this.focusedChild.set("tabIndex", "-1");
	this._set("focusedChild", null);
  • the second time the user clicks "File" in the MenuBar, _onChildFocus() isn't called, because there's no focusin event because "File" is already focused... this.focusedChild remains null
  • the second time the menu closes, MenuBar tries to restore focus by using this.focusChild, and gets an exception

comment:4 Changed 9 years ago by bill

Resolution: fixed
Status: newclosed

In [30834]:

Stop depending on this.focusedChild to find the MenuItem that popped up the Menu. It may not be set. Fixes #16784 !strict.

Also change use of deprecated connect() method, and use simpler check to tell if focus has been moved out of the MenuBar hierarchy or is on a descendant.

Note: See TracTickets for help on using tickets.