select2 / select2/select2

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

Open
#5,781 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

4.x confirmed bug feature: dropdown help wanted
Dominant language
JavaScript
Stars
25.9k
Forks
6.1k
Avg merge
8d 53m
Merged PRs (30d)
4

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

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

Start with the linked JSFiddle and reproduce the behavior using a Select2 element inside Shadow DOM. Trace how clicks outside the dropdown and Select2 element are handled, then verify that the dropdown closes when the outside click occurs.

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.