Skip to main content

Search and Top Navigation

#9469 closed bug (fixed)

Opened August 01, 2013 12:55AM UTC

Closed August 03, 2013 09:43PM UTC

Last modified November 26, 2013 07:56PM UTC

on(“menuselect”) not firing every time

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

Creating a menu with jQueryUI, I noticed that if you select a menuitem, it fires the appropriate event properly. However, if you then select another menuitem right away (without clicking on anything outside the menu first), it does not fire the menuselect event and simply treats the a tag as a regular link (this pattern repeats: 1 okay, 1 ignored, 1 okay, 1 ignored, etc...)

Here is a jsfiddle that demonstrates the issue: http://jsfiddle.net/J9eyv/4/

(1) Broken: Click an option, then click another one.

(2) Works: Click an option, click outside the menu, then click another option.

The code is modeled after the jQueryUI demo here: http://api.jqueryui.com/menu/#event-select

Was raised on stackoverflow here: http://stackoverflow.com/questions/17982109/jqueryui-onmenuselect-not-firing-every-time/17982286

Attachments (0)
Change History (8)

Changed August 01, 2013 12:47PM UTC by tj.vantoll comment:1

resolution: → notabug
status: newclosed

This only happens if you

return false
or prevent the default action in the
select
event. Don't do that; it's essentially saying you want to prevent the selection which doesn't make sense here.

Changed August 01, 2013 01:10PM UTC by scottgonzalez comment:2

component: ui.coreui.menu
resolution: notabug
status: closedreopened

I don't think the menu should get out of sync like that though, even if the default is prevented.

Changed August 01, 2013 06:44PM UTC by EleventyOne comment:3

_comment0: Replying to [comment:1 tj.vantoll]: \ > it's essentially saying you want to prevent the selection which doesn't make sense here. \ \ No, it's saying that you don't want to prevent the default behaviour of an a tag that goes nowhere, which makes perfect sense.1375382691226909
_comment1: Replying to [comment:1 tj.vantoll]: \ > it's essentially saying you want to prevent the selection which doesn't make sense here. \ \ Not exactly. I think it's saying that you want to prevent the default behaviour of an a tag that goes nowhere, which makes perfect sense.1375382723845371
_comment2: Replying to [comment:1 tj.vantoll]: \ > it's essentially saying you want to prevent the selection which doesn't make sense here. \ \ Not exactly. I think it's saying that you want to prevent the default behaviour of an `a` tag that goes nowhere, which makes perfect sense.1375383017387118

Replying to [comment:1 tj.vantoll]:

it's essentially saying you want to prevent the selection which doesn't make sense here.

Not exactly. I think it's saying that you want to prevent the default behaviour of an a tag that goes nowhere, which makes perfect sense.

EDIT:

Oh, I see what you mean. So perhaps instead I should have put the return false in an event tied to the a tags themselves, and not the "menuselect" event. I can see that point of view. But from a design perspective, that's a little awkward, since the menu elements have to be a tags - i.e., if I have to tie events to the a tags anyway, why am I bothering to use the "menuselect" event at all?

Changed August 02, 2013 10:52AM UTC by tj.vantoll comment:4

Upon further digging it's actually not the

preventDefault
, but rather the
stopPropagation
. Stopping propagation prevents this from being invoked and the
mouseHandled
flag from being reset.

Sent a pull request with a proposed workaround: https://github.com/jquery/jquery-ui/pull/1044

Changed August 03, 2013 09:43PM UTC by TJ VanToll comment:5

resolution: → fixed
status: reopenedclosed

Menu: Only set the mouseHandled flag if the event is going to bubble. Fixes #9469: on( "menuselect" )

not firing every time.

Changeset: 484e382259f1c1c56b151a97ddf8a894f94d17ea

Changed August 03, 2013 09:48PM UTC by tj.vantoll comment:6

milestone: none1.11.0

Changed November 26, 2013 07:51PM UTC by TJ VanToll comment:7

Menu: Only set the mouseHandled flag if the event is going to bubble. Fixes #9469: on( "menuselect" )

not firing every time.

(cherry picked from commit 484e382259f1c1c56b151a97ddf8a894f94d17ea)

Changeset: b02a32f4b3d7a0588949f2961a74d613beeaea48

Changed November 26, 2013 07:56PM UTC by scottgonzalez comment:8

milestone: 1.11.01.10.4