Select: Selection is not shown if Option is marked as disabled
Describe the bug
If the current value is from a disabled option, the label isn't displayed at all. But it's a common pattern to disable already selected options that are selected in another control to avoid duplicates in a related list. I discovered this issue after I migrated an from v17 to v19
Pull Request Link
No response
Reason for not contributing a PR
- [x] Lack of time
- [x] Unsure how to implement the fix/feature
- [x] Difficulty understanding the codebase
- [ ] Other
Other Reason
No response
Reproducer
https://stackblitz.com/edit/af4eejxh?file=src%2Fapp%2Fselect-basic-demo.html,src%2Fapp%2Fselect-basic-demo.ts,src%2Fmain.ts
Environment
Stackblitz Fork from Select-Demo
PrimeNG 19 as of 19.4 has the same issue
Angular version
19.x, 20.x
PrimeNG version
v20
Node version
No response
Browser(s)
No response
Steps to reproduce the behavior
Value is Selected but in Options disabled. Example: https://stackblitz.com/edit/af4eejxh?file=src%2Fapp%2Fselect-basic-demo.html,src%2Fapp%2Fselect-basic-demo.ts,src%2Fmain.ts
Expected behavior
Selected Value should still be visible
I think I found the culprit: https://github.com/primefaces/primeng/blob/f1be3555ea2321158da6ccdcdf9a3c05f3288f8c/packages/primeng/src/select/select.ts#L1618-L1620
isValidOption called from stack started by the label computed checks if the option is disabled with this.isOptionDisabled(option).
Though I am unsure how to approach a fix. Maybe introduce a new boolean Input allowDisabledOptions ?
Running into the same issue. It was introduced in 19.1.1, in 19.1.0 it still works fine. My guess is, that this is the culprit: https://github.com/primefaces/primeng/pull/18112/files
still exists in 20+ https://stackblitz.com/edit/jq2wj7cc-cqcmjj6h hoping this can get fixed soon
this issue doesn't exist when the items are grouped: https://stackblitz.com/edit/jq2wj7cc-xelf5mw8