question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Dropdown position is incorrect when ng-select is placed in a scrollable container

See original GitHub issue

Bug Description

In https://github.com/ng-select/ng-select/issues/237 and https://github.com/ng-select/ng-select/pull/238 ng-select learned to display its dropdown above the select in case there is no enough room below. It does not seem to work when ng-select is placed in a scrollable container.

To Reproduce Steps to reproduce the behavior:

  1. Visit the demo page https://stackblitz.com/edit/angular-rxjygd.
  2. Scroll the scrollable element to the end to reveal the test ng-select.
  3. Expand ng-select by pressing the arrow button.
  4. The dropdown appears under the select and is not fully visible to the user until he/she scrolls the scrollable element further down.

ng-select incorrect dropdown position demo

Expected behavior In the reproduction scenario, the dropdown should be placed above the select so that it is fully visible to the user.

I believe that generally NgDropdownPanelComponent._calculateCurrentPosition method should consider ng-select’s position relative to its nearest parent with overflowY != 'visible'. If there is no such parent, the method should rely on body / window as it does unconditionally now.

Environment: (does not really matter)

  • OS: Windows 10 x64
  • Browser: Google Chrome 68.0.3440.106 (Official Build) (64-bit)

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:7
  • Comments:24 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
varnastadeuscommented, Jul 12, 2019

I think appendTo="body" is valid solution and I am not sure if something else needs to be done here. Don’t forget to set

body {
    position: relative;
}

with appendTo body as mentioned in docs

1reaction
earshinovcommented, Mar 30, 2019

For the record, here is what happens with appendTo="body":

appendTo body

Read more comments on GitHub >

github_iconTop Results From Across the Web

ng-select drop down position is not correct in scroll able div
It will not update the position once opened when you scroll (not supported), you need to close the drop down when scrolling happens...
Read more >
Ngx Scroll Ng Select Issue
Starter project for Angular apps that exports to the Angular CLI.
Read more >
ct-cue/ng-select
When multiple = true, allows to set a limit number of selection. [hideSelected], boolean, false, no, Allows to hide selected items. [multiple] ...
Read more >
ng-select
When I try to resize screen width while the select is opened, the dropdown panel position isn't updated. Calling adjustPosition on dropdownPanel doesn't ......
Read more >
Data sources
Most common case is showing data from backend API and with ng-select this is extremely simple since you ... You can also set...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found