You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A EuiSelect with hasNoInitialSelection creates a black option at the begging of the select. This is very useful when you don't want to preselect a value. If you select a value, and then you set it to undefined the black option is not selected. Example:
<EuiSelect
fullWidth
data-test-subj="subcategorySelect"
hasNoInitialSelection
options={subcategoriesOptions}
value={subcategory ?? undefined}
onChange={(e) => {// set the subcategory}}
/>
If I change value={subcategory ?? undefined} to value={subcategory ?? ''} (empty string) then the blank option is selected.
Steps to reproduce:
Select an option.
Make the value undefined. Example: You press a button that sets the value to undefined.
I think the component should handle both cases. Thanks!
The text was updated successfully, but these errors were encountered:
EuiSelect is just a regular HTML select in disguise. Regular selects do not allow undefined values. If you want one, you need to pass them as an empty option in your array and assign it. Read issue too quickly in the morning, but this is why it happens. It's actually an empty string in disguise. :)
A
EuiSelect
withhasNoInitialSelection
creates a black option at the begging of theselect
. This is very useful when you don't want to preselect a value. If you select a value, and then you set it toundefined
the black option is not selected. Example:If I change
value={subcategory ?? undefined}
tovalue={subcategory ?? ''}
(empty string) then the blank option is selected.Steps to reproduce:
undefined
. Example: You press a button that sets the value toundefined
.I think the component should handle both cases. Thanks!
The text was updated successfully, but these errors were encountered: