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

Dropdown autowidth doesn't auto-size in some cases #2973

Closed
mroskamp opened this issue Jun 2, 2017 · 6 comments
Closed

Dropdown autowidth doesn't auto-size in some cases #2973

mroskamp opened this issue Jun 2, 2017 · 6 comments
Assignees
Labels
Status: Pending Review Issue or pull request is being reviewed by Core Team Type: Bug Issue contains a bug related to a specific component. Something about the component is not working
Milestone

Comments

@mroskamp
Copy link
Contributor

mroskamp commented Jun 2, 2017

I'm submitting a ... (check one with "x")

[ X] bug report => Search github for a similar issue or PR before submitting
[ ] feature request => Please check if request is not on the roadmap already https://github.com/primefaces/primeng/wiki/Roadmap
[ ] support request => Please do not submit support request here, instead see http://forum.primefaces.org/viewforum.php?f=35

Plunkr Case (Bug Reports)
http://plnkr.co/edit/bbBtMXd7M4M6oHKgYy5a?p=preview

Current behavior
If a dropdown isn't visible at component initialization time, the autowidth feature doesn't size the dropdown properly. Instead, it has a width of 30px, since the 'select' element is detected as having a width of 0px. See dropdown.ts:updateDimension().

Expected behavior
A dropdown with autowidth enabled should have the correct size, even if it's not visible on initialization.

Minimal reproduction of the problem with instructions

  1. Add a dropdown component with options of various lengths
  2. Make the dropdown hidden by default
  3. Add a button to toggle the hidden state of the dropdown
  4. Run the demo, click the toggle button. Notice how the dropdown is only 30px wide.

http://plnkr.co/edit/bbBtMXd7M4M6oHKgYy5a?p=preview

What is the motivation / use case for changing the behavior?
We have a dropdown with dynamic contents that's located in a modal. Due to the dynamic content of the dropdown, we want the dropdown to auto re-size. Since the dropdown is in a modal it's not visible on initialization, it's only visible after the user causes the modal to open, so the dropdown doesn't get sized properly.

To work around this issue, I've added an event handler in my component to manually call dropdown.updateDimensions() on the modal's show event. It'd be nice if this workaround wasn't needed and the dropdown automatically resized when it became visible.

  • Angular version: 4.0.0

  • PrimeNG version: 4.0.1

  • Browser: all

  • Language: all

@cagataycivici cagataycivici self-assigned this Jun 23, 2017
@cagataycivici cagataycivici added this to the 4.1.1 milestone Jun 23, 2017
@cagataycivici cagataycivici added the Type: Enhancement Issue contains an enhancement related to a specific component. Additional functionality has been add label Jun 23, 2017
@cagataycivici cagataycivici modified the milestone: 4.1.1 Jul 19, 2017
@steigerm
Copy link

steigerm commented Aug 3, 2017

I even have this problem with the dropdown initially visible.
I made a component consisting of only one dropdown and used in one component it displays fine but used in another one its width is 30px (like desribed in this issue).
The main difference is that in the non-working case the dropdown is displayed inside a p-tabView.
Maybe this is the source of the problem?

btw, I see this as a bug not an enhancement.

@kito99
Copy link

kito99 commented Dec 20, 2017

I agree with @steigerm; this definitely looks like a bug. I see this with p-dropdown inside of a p-overlayPanel that isn't visible initially.

@fugree
Copy link

fugree commented Feb 14, 2018

any update on this. i'm having same problem. dropdown that is populated from web api / service call. If you select an item, the dropdown re-sizes correctly, but until then it is sized like the OP describes

@jakob-bebop
Copy link

+1 i get a feeling I have to add [autoWidth]='false' in a lot of places...

@mf085
Copy link

mf085 commented Feb 16, 2018

This issue also appears on Tabview. I solved it with lazy loading feature. There you add an ng-template tag. For further details check here

@Royvhorck1
Copy link

Royvhorck1 commented Mar 21, 2018

Is there already an update or workaround for this?
I am having the same problem when opening a dialog with a tabview inside: here the dropdown is also very small width.
when having a dropdown in the main component there is no problem.
ps. my dropdown in the tabview is always visible. regarding the visibility mentions above

@Merve7 Merve7 added the Status: Pending Review Issue or pull request is being reviewed by Core Team label Jul 5, 2018
@Merve7 Merve7 added this to the 6.0.1 milestone Jul 5, 2018
@Merve7 Merve7 removed the Status: Pending Review Issue or pull request is being reviewed by Core Team label Jul 6, 2018
@cagataycivici cagataycivici added Type: Bug Issue contains a bug related to a specific component. Something about the component is not working Status: Pending Review Issue or pull request is being reviewed by Core Team and removed Type: Enhancement Issue contains an enhancement related to a specific component. Additional functionality has been add labels Jul 9, 2018
@Merve7 Merve7 closed this as completed in 30fd651 Jul 10, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Pending Review Issue or pull request is being reviewed by Core Team Type: Bug Issue contains a bug related to a specific component. Something about the component is not working
Projects
None yet
Development

No branches or pull requests

9 participants