Skip to content

Reposition dropdown whenever items are selected#5590

Merged
kevin-brown merged 2 commits into
developfrom
GH-4377
Jul 28, 2019
Merged

Reposition dropdown whenever items are selected#5590
kevin-brown merged 2 commits into
developfrom
GH-4377

Conversation

@kevin-brown

Copy link
Copy Markdown
Member

This pull request includes a

  • Bug fix
  • New feature
  • Translation

The following changes were made

  • Reposition dropdown whenever items are selected
  • Attach positioning handlers at bind time

If this is related to an existing ticket, include a link to it as well.

Fixes #4377

This fixes an old bug where if you had a multiple select with the
`closeOnSelect` option set to `false` and many options being
selected, the dropdown would not reposition itself if the selected
options expanded the container down another line. This was because
the dropdown was only being repositioned when it was opened, closed,
or if something around it was scrolled or resized. Unfortunately,
in most cases none of these happened and the dropdown would start
covering the selections.

This was fixed by telling Select2 to resize the dropdown when new
options are selected or existing options are unselected.

Fixes #4377
The positioning handlers have been attached at the time that the
dropdown is opened since when they were first committed many years
ago. It's not actually clear why this was being done, since they
don't rely on anything involving the dropdown being open. This
removes the flag and process for setting these handlers only after
the dropdown was opened for the first time, and moves these handlers
to always be set at bind time.
@kevin-brown kevin-brown added this to the 4.0.9 milestone Jul 28, 2019
@kevin-brown kevin-brown merged commit 525f661 into develop Jul 28, 2019
@kevin-brown kevin-brown deleted the GH-4377 branch July 28, 2019 18:49
maxwellfet928 pushed a commit to maxwellfet928/select2 that referenced this pull request Jun 8, 2026
* Reposition dropdown whenever items are selected

This fixes an old bug where if you had a multiple select with the
`closeOnSelect` option set to `false` and many options being
selected, the dropdown would not reposition itself if the selected
options expanded the container down another line. This was because
the dropdown was only being repositioned when it was opened, closed,
or if something around it was scrolled or resized. Unfortunately,
in most cases none of these happened and the dropdown would start
covering the selections.

This was fixed by telling Select2 to resize the dropdown when new
options are selected or existing options are unselected.

Fixes select2#4377

* Attach positioning handlers at bind time

The positioning handlers have been attached at the time that the
dropdown is opened since when they were first committed many years
ago. It's not actually clear why this was being done, since they
don't rely on anything involving the dropdown being open. This
removes the flag and process for setting these handlers only after
the dropdown was opened for the first time, and moves these handlers
to always be set at bind time.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Drop-down area is not repositioned if still open when multi-select area changes size (e.g. closeOnSelect=false)

1 participant