Skip to content

Fix bug where dropdowns pointing upwards were incorrectly positioned#5621

Merged
kevin-brown merged 1 commit into
developfrom
GH-5619
Aug 28, 2019
Merged

Fix bug where dropdowns pointing upwards were incorrectly positioned#5621
kevin-brown merged 1 commit into
developfrom
GH-5619

Conversation

@kevin-brown

Copy link
Copy Markdown
Member

This pull request includes a

  • Bug fix
  • New feature
  • Translation

The following changes were made

  • Switch back to doing late binds for the positioning handlers for dropdowns

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

Fixes #5619
Fixes #5620

This is how it used to work pre-4.0.9, where the bound handlers for
resizing and positioning the dropdown were bound at the first time
that the dropdown was opened. This was changed for the 4.0.9 release
as a part of 3f75227 where it was not clear why this late binding
was happening, so it was removed to simplify the code.

The late binding is necessary because the handlers within results for
generating the results, and thus the content within the dropdown,
are bound after the handlers for the dropdown are bound. This results
in situations where the handlers for positioning the dropdown are
bound before the dropdown is updated with content, resulting in the
positioning being calculated for the old content and thus being
incorrectly placed. By binding the positioning handlers after the
dropdow is opened for the first time, we can ensure that the
positioning handlers are bound after the result handlers, so we
won't have to worry about this issue.

The handlers are only bound once because they only need to perform
all the calculations a single time. There is no need to keep checking
all of the calculated styles more than we need to, so this is guarded
by a flag which ensures it is only bound a single time per dropdown.

Fixes #5619
Fixes #5620
@kevin-brown kevin-brown added this to the 4.0.10 milestone Aug 28, 2019
@kevin-brown kevin-brown merged commit 9e4f842 into develop Aug 28, 2019
@kevin-brown kevin-brown deleted the GH-5619 branch August 28, 2019 02:27
maxwellfet928 pushed a commit to maxwellfet928/select2 that referenced this pull request Jun 8, 2026
Fix bug where dropdowns pointing upwards were incorrectly positioned
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

1 participant