primereact
primereact copied to clipboard
Dropdown: clear icon and value not shown when options are empty
Describe the bug
When using the Dropdown component with showClear={true}, the clear icon does not appear if options is empty, even though the dropdown has a value.
Additionally, if options is empty, the value itself is not displayed — even when a custom valueTemplate is provided to explicitly render it.
This creates issues in scenarios where options are loaded asynchronously or only available at certain times (e.g., after a button click or API call). In these cases, I would still like to show the currently selected value and show the clear icon if value is set and showClear={true}
Reproducer
https://stackblitz.com/edit/zavs11yi
System Information
primereact: latest
react: 18.3.1
Steps to reproduce the behavior
- Render a Dropdown with a non-empty value and showClear={true}.
- Pass an empty array to options.
- Observe that both the value and the clear icon are missing.
Expected behavior
No response