jquery / jquery/jquery-ui

The selectmenuselect event erroneously fires, despite not making a selection

Open
#2,317 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Behavior shared with 1.12 Comp: Selectmenu
Dominant language
JavaScript
Stars
11.3k
Forks
5.2k
PR merge metrics
No merged PRs in 30d

Description

This is the same exact bug from 2017 which was filed at https://bugs.jqueryui.com/ticket/15115/#comment:1

The comment is more accurate than the OP's post.

The OP gives an example at http://jsbin.com/cubulifice/edit?html,js,console,output

If you open the dropdown menu, then click outside of the dropdown to close it, and rinse and repeat a few times - the event fires, even though nothing was selected.

This can be fixed by inserting this code after function() { :

if($('#speed-menu .ui-menu-item').is(':hidden')) {
  console.log('Ignoring erroneous selection');
  return;
}

Similarly, here is my own example: https://jsfiddle.net/eucq05ok/

In my own tests, it is easier to reproduce the bug if you hover over some of the options before clicking outside of the dropdown.

This can be fixed by inserting the same code, but changing #speed-menu to #area-menu.

I observed this bug on the latest version of jQuery (3.7.1) and the latest version of jQuery UI (1.14.1).

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the event using the linked jsbin or jsfiddle, including hovering options before clicking outside the dropdown, and compare the behavior with the historical ticket. Trace the selectmenuselect event entry point and add regression coverage showing that closing without a selection does not fire it; verify that genuine selections still do.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, jquery
Domain
frontend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.