-
-
Notifications
You must be signed in to change notification settings - Fork 6.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Dropdown positioned too high when appended to absolute parent with scrollTop. #4381
Comments
I'm pretty sure this was fixed in the upcoming 4.0.3 release, but it might be a different issue. Can you expand upon the issue you are facing by adding a few more pieces of information to your bug report?
The contributing guide contains a useful section with a few questions which can help us track down the bug and speed up the process of finding a fix for it. The creation of an isolated test case would also be useful. |
@kevin-brown this is also happening in the 4.0.3 version |
This is happening for me to on an application where i am using select 2. I also can reproduce it on the repo examples page as stated above. Using Win 10, checked with Firefox 48, Chrome 53, Edge 38 and Opera 39. In all cases, a first open of the select2 search box places it a little offset to the top, and then after searching, selecting a result, and opening it again the search box is placd just where it would site if the old search results were shown. Closing and opening again clears the issue. I will do some extra tests. Maybe selecting a value bypasses clearing some data somehow that a "natural" closing addresses. |
@kevin-brown Updated original test case to 4.0.3 shows the same error for me. Chrome 54. https://plnkr.co/edit/aSmiYLalXof5FpdkYrUW?p=preview |
I have the same problem |
Closing this as a duplicate of #4614. |
I found the same issues on my project.. |
@ChangDev123 please write the code example |
See this plunker:
https://plnkr.co/edit/JN8THx7eEaOX76h7bELN?p=preview
Bug seen in FF, safari, chrome.
The issue is because an absolute (absolute or fixed) container's edge shifts upward when you scroll within it.
Select2 uses the offset from document edge to the bottom edge of the fake select to position the dropdown. For appending the dropdown to a positioned parent, the parent's own offset is subtracted. This is complete for most cases.
But if the fake select is in a container that overflows a fixed container (the
dropdownParent
), when you scroll the select up, its offset is reduced, but its top positioning relative to the edge of the dropdownParent is not, because the dropdownParent's edge is pushed up with it. The scrollTop of the dropdownParent needs to be added to the css positioning.As you can see in the screenshot, Ive scrolled the static blue box up about 80px within the fixed red box. The dropdown
top
needs another 80px.I added this near the end of
_positionDropdown
and it fixed the issue for me.I can make a pull request if we think its the best approach.
The text was updated successfully, but these errors were encountered: