primeng icon indicating copy to clipboard operation
primeng copied to clipboard

Select: Selection is not shown if Option is marked as disabled

Open gregorAutomatics opened this issue 1 year ago • 3 comments

Describe the bug

Image

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

Image

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

Image Image

Expected behavior

Selected Value should still be visible

gregorAutomatics avatar Aug 27 '25 10:08 gregorAutomatics

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 ?

gregorAutomatics avatar Aug 27 '25 16:08 gregorAutomatics

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

schroeerth avatar Sep 16 '25 14:09 schroeerth

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

bvx5009 avatar Sep 17 '25 17:09 bvx5009