select2/select2

Shadow DOM Issue: Selection Dropdown Hangs Open When Clicked Elsewhere On Page

Open

#5,781 opened on Feb 25, 2020

View on GitHub
 (1 comment) (0 reactions) (0 assignees)JavaScript (25,772 stars) (6,283 forks)batch import
4.xconfirmed bugfeature: dropdownhelp wanted

Description

As a user of Select2, I would like the dropdown menu to close when I click elsewhere on the page because this is the expected and natural behavior of selection dropdowns.

Expected Behavior: When a the selection dropdown is open and a click happens outside of the dropdown menu, the dropdown menu should close.

Actual Behavior: The dropdown does not close when a click event occurs outside of the open dropdown menu.

Steps To Reproduce: Create a Select2 element in the Shadow DOM and configure it to open a dropdown menu when a user is selecting an option. Click outside of the dropdown menu and Select2 element. The dropdown menu will hang open.

Notes: I consider this a bug and not a feature request because it seems that the default behavior of Select2 is that clicking outside of the dropdown menu closes it. JSFiddle: https://jsfiddle.net/mslocum/kfqd7nga/

Contributor guide