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.

Target a specific dropdown panel by css class to individually set dropdown-panel max-height

See original GitHub issue

Is your feature request related to a problem? Please describe. Not sure if that can be solved currently, but I seem to miss a way to target a specific ng-dropdown-panel in css, in order to adjust max-height of the foldout.

The ultimate goal is to avoid this sort of situations: image

but there can also be an opposite situation where a specific dropdown can use much more screen estate than what it is using.

Being able to target a specific dorpdown panel becomes critical:

  • with appendTo="body" (or anything else) - which is where ng-dropdown-panel is no longer a descendant of ng-select.
  • when a form is displayed within a modal
  • when a form has multiple instances of ng-select

Describe the solution you’d like My first, cheapest shoot would be to re-use labelForId of the parent as class on the ng-dropdown-panel.

Assume a control with labelForId="users", the markup looks like so:

<ng-select bindvalue="id" bindlabel="text" ng-reflect-bind-value="id" ng-reflect-bind-label="text" ng-reflect-append-to="" ng-reflect-items="[object Object],[object Object" ng-reflect-is-disabled="false" ng-reflect-searchable="false" ng-reflect-clearable="false" ng-reflect-multiple="false" ng-reflect-dropdown-position="auto" ng-reflect-selectable-group="false" ng-reflect-close-on-select="true" ng-reflect-virtual-scroll="true" ng-reflect-label-for-id="users" class="ng-select ng-select-single ng-pristine ng-valid ng-touched ng-select-opened ng-select-bottom">

<ng-dropdown-panel role="listbox" aria-label="Options" class="ng-dropdown-panel ng-select-bottom" ng-reflect-virtual-scroll="true" ng-reflect-buffer-amount="4" ng-reflect-append-to="" ng-reflect-position="auto" ng-reflect-header-template="[object Object]" ng-reflect-items="[object Object],[object Object" ng-reflect-marked-item="[object Object]" id="abfe3714e804" style="opacity: 1;">
...
</ng-dropdown-panel>
</ng-select>

Please note that in ng-dropdown-panel there is no attribute or class that connects it to its parent ng-select.

In this case I would like ng-dropdown-panel to use its parent’s labelForId among its classes, so it could be targeted as ng-dropdown-panel.users.

Describe alternatives you’ve considered I tried to see if the appendTo element maybe also serves to restrict the dropdown panel’s rendering boundaries, but apparently not.

Additional context None.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:1
  • Comments:6

github_iconTop GitHub Comments

1reaction
DzmVasileuskycommented, Jun 3, 2022

@rmcsharry This library doesn’t seem to be supported anymore. What I have done:

<ng-select (open)="onDropdownOpen()">...</ng-select>
...

onDropdownOpen () {

    setTimeout(() => {

        this.renderer2.addClass(document.querySelector('.ng-dropdown-panel'), 'custom-class');

    }); // timeout is needed to wait for dom element to be inserted

}

0reactions
github-actions[bot]commented, Aug 3, 2022

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions 🎆

Read more comments on GitHub >

github_iconTop Results From Across the Web

ng-select max height dropdown panel - css - Stack Overflow
I'm trying to set the max height of an ng-select control and I'm using the following css ng-dropdown-panel.custom-class { max-height: 200px; }.
Read more >
How to style a dropdown using CSS? - GeeksforGeeks
In this article, we will know how to style the dropdown list using CSS & will understand its implementation through the examples.
Read more >
Dropdowns - Bootstrap
Dropdowns are toggleable, contextual overlays for displaying lists of links and more. They're made interactive with the included Bootstrap dropdown ...
Read more >
How to adjust (max-height) on a specific Selec2 dropdown?
This will change it for all .select2 containers. How do I target a specific .select2 dropddown? I've tried targeting the custom CSS class...
Read more >
Line-by-line: advanced CSS tricks for click-to-open drop-down ...
The combobox class is for a combo box · The dropdown class is for menus and combo boxes that drop down when the...
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