ng-select: Dropdown doesn't adjust its position (top or bottom) when the options change due to a typeahead

Describe the bug In case of dynamically populate options (typeahead), the position of the dropdown (top or bottom) is not updated when the items change.

To Reproduce

  1. Create a page with an ng-select that’s at the bottom of the page
  2. Set dropdownPosition to 'auto'
  3. Set a typeahead and type something that results in only a few options, so that they fit when the dropdown opens at the bottom.
  4. Now type something that results in a lot of options, so that the “bottom” position is not suitable anymore.

Expected behavior I expect the dropdown to adjust it’s position when the option items change, but it doesn’t.

My workaround is the following, tapping into the typeahead:

setTimeout(() => {
    (this._ngSelect.dropdownPanel as any)._handleDropdownPosition();
}, 1);

But it’s not nice because it depends on a private method.

About this issue

  • Original URL
  • State: open
  • Created 2 years ago
  • Reactions: 3
  • Comments: 22

Most upvoted comments

🏓