Opened 13 years ago

Closed 13 years ago

#9846 closed defect (fixed)

Dijit.Menu disappears unexpectedly

Reported by: zhaojing Owned by: Douglas Hays
Priority: high Milestone: 1.4
Component: Dijit Version: 1.3.2
Keywords: menu issue Cc:
Blocked By: Blocking:


The description of the defect: Dijit.Menu disappears unexpectedly when the mouse hovers among different dijit.MenuItem? frequently.

I probably found the reason: The code "setTimeout(dojo.hitch(popup,"focus"),0)" which use setTimeout() to override the onmousehover event in the function "_openPopup" in the file Menu.js causes the defect. Because when the mouse hovers a menuItem, the submenu of it will be opened and the focus event happens with a little delay because of the timeout, at this time, the mouse move onto the next menuItem quickly then the same thing happens which may cause the two focus events happening at the same time,so the onBlur event of the menu happens for it doesn't know where is the focus now. Then the menu is closed.

A way to fix the defect: Mark the focus timeout in the "_openPopup", then clear the timeout when the menuitem is hovered.(In the onItemHover function in menu)

      if(this.popupFocusTimer){ clearTimeout(this.popupFocusTimer); }//my fix code
      this.popupFocusTimer = setTimeout(dojo.hitch(popup,"focus"),0);//my fix code
onItemHover: function(/*MenuItem*/ item){
   if(this.popupFocusTimer){             //my fix code
      clearTimeout(this.popupFocusTimer);//my fix code

Change History (3)

comment:1 Changed 13 years ago by bill

Hi zhaojing, thanks for tracing down the issue. Let me ask you a few questions:

  1. If the mouse is moving quickly then why is _openPopup() called at all? It's got a 500ms delay and it's cancelled if the mouse is moved off of the parent PopupMenuItem. Or is this issue with MenuBar where there's no dealy?
  1. In your description, you talk about the mouse moving to "the next menuitem". Does that refer to an item in the parent or the child? For example, let's look at the MenuBar in test_Menu.html:
File           Edit        View     Help
| New     |
| Open    |
| Save    |
| Save As |

If the File menu is open and then the user moves the mouse to the Edit menu, it's natural for the File menu to disappear. Is that the case you mean? Or is the edit menu disappearing? O

Can you explain an example using the File and Edit menus and list where the mouse moves and when the timeouts occur?

comment:2 Changed 13 years ago by bill

Milestone: tbd1.4
Owner: set to Douglas Hays
Priority: highnormal

I think this will be fixed by the work Doug is doing on Menu now.

comment:3 Changed 13 years ago by Douglas Hays

Resolution: fixed
Status: newclosed

(In [20098]) Fixes #6773, #8624, #9846 !strict. Added ESC keydown handling in the popup manager for WebKit? so menus can be closed with the keyboard. Added a pending-close state to menus so if the mouse touches something else but moves back to a target menu, then the close is cancelled. Added ability to close MenuBar? menu's by reclicking the menubar item to be consistent with other applications. Collpased multiple deferred focus events to prevent incorrect blurring. Added numerous automated tests to demonstrate changed behavior. All tests ran on WIndows. Mac is currently experiencing robot issues. Removed the Hover CSS style if the keybaord is used to select a different item in the same menu after moving the mouse to hover a slibling item to prevent multiple menu selections. Removed isActive after a menu item is selected or on a menu blur event so the menu doesn't popup again on subsequent hovering. Removed _onFocus handling from Menu since it can fire after a menu has closed and now isActive is set from onItemClick.

Note: See TracTickets for help on using tickets.