Skip to content
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

p-dropdown: Panel not positioned correctly under some specific filter circumstances #16050

Closed
antonio-cordoba opened this issue Jul 17, 2024 · 2 comments
Labels
Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible

Comments

@antonio-cordoba
Copy link

Describe the bug

I have a dropdown with these specific characteristics:

  • The panel is styled to fit content.
  • My host component has key event handler to filter options when an alpha key is pressed.
  • The filter is a 'starts with' and it resets at every keystroke.
  • My options have labels with significantly different lengths.
    When a panel is displayed, it gets positioned correctly based on the available space around the dropdown and the size of the panel. It can be above or below the dropdown, and it may extend to the right or the left based on how close it is to the edge. All this is great!
    However, when the panel is shown extending to the left and we use the keyboard to filter a subset of shorter description options, the panel gets re-sized but not re-positioned, resulting in a panel that is far from its dropdown as shown in this screen capture.
    image

Environment

Our internal application has a page with multiple instances of these dropdowns.
The layout of the page is data driven so we have multiple layouts where at times there are only a few dropdowns and most time we have a more significant amount of these.
The page where these dropdowns are used has other information the users need on the screen so it is important for users to see the options close to the specific dropdown they are working with.
Our users for the most prefer to work with the keyboard.

Reproducer

https://stackblitz.com/edit/dropdown-panel-sample?file=src%2Fcomponents%2Fapp-component.html

Angular version

18.0.0

PrimeNG version

17.18.4

Build / Runtime

Angular CLI App

Language

TypeScript

Node version (for AoT issues node --version)

22.3.0

Browser(s)

Chrome 126

Steps to reproduce the behavior

Please see stackblitz sample above.
Two steps:

  1. Display the panel with the mouse.
  2. Press letter 'o' on the keyboard to filter the options on the panel with shorter labels.

Expected behavior

After re-size, panel should re-position close to the dropdown according to current rules (below the dropdown if possible, otherwise above; extend to the right if possible, otherwise to the left.
image

@antonio-cordoba antonio-cordoba added the Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible label Jul 17, 2024
@antonio-cordoba
Copy link
Author

antonio-cordoba commented Jul 18, 2024

While playing with the stackblitz I did find a workaround... Make a call to pDropdown?.overlayViewChild?.alignOverlay() on a timeout right after setting the filter. That seems to do the half of the trick, but there are still issues.
The main issue with the workaround is that although the overlay now repositions after setting the filter, it still doesn't reposition back after clearing the filter (pressing any non-alpha key like Shift or Backspace)
See update on the stackblitz reproducer
I still believe this should be done internally at the PrimeNG component, not by workarounds of the component consumers.

@mertsincan
Copy link
Member

Hi,

So sorry for the delayed response! Improvements have been made to many components recently, both in terms of performance and enhancement. Therefore, this improvement may have been developed in another issue ticket without realizing it. You can check this in the documentation. If there is no improvement on this, can you open a new issue so we can include it in our roadmap?

Thanks a lot for your understanding!
Best Regards,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible
Projects
None yet
Development

No branches or pull requests

2 participants