Dropdown preselection might fail if options initialized later
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
Current behavior When selection value is set before a drop down menu's options list values, the selected item is not displayed.
Use case example: A ticketing system in which a user selects a ticket from a datatable within a tab view with dynamic tabs. Upon selection the ticket is set as a drop down menu's selected value. This drop down is part of a form in another tab of the tab view. The selected ticket is passed to this form from a parent component via @input(). Now when the user moves to the tab that contains the form holding this drop down the component for this tab's ngOninit initializes the dropdown's options list. Due to the fact that the list was initialized after the selected value causes the drop down to not show the selected value.
SEE CLOSED ISSUE #651
Expected behavior When the options are initialized after the selected value the drop down menu will correctly display the selected value.
What is the motivation / use case for changing the behavior? dynamic content generation where a value may be set prior to the components list values are generated. See the example provided above.
Please tell us about your environment: Windows 8, Eclipse Mars, Jboss EAP 5.x
-
Angular version: 2.0.X 4.1.1
-
PrimeNG version: 2.0.X 4.2.1
-
Browser: Chrome, FireFox, IE
Is there any ETA on when this issue may be addressed? I ask, as I have a project that is on hold, pending a resolution to this issue.
I believe we are having this issue as well. Is there an update on this?
I'm also having problem espe used [group] = "true" elment p-dropdown, I'm initializing the value and the dropdown is not updating the screen
Same issue, I get initial value from url and apply this value as preselected value for dropdown. Dropdown list is subscribable from ngrx and comes later. In this case dropdown doesn't update value.
This works for me, make sure you create a new instance of the options as change detection is not triggered when using array methods like push.