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
that renders normally with one issue: the first option (with value, state) is selectable and requires validation.
That behavior can be altered with <option style="display: none;" value="">State</option>. Displaying it as none makes sure that:
It exists but is not selectable
Selecting a different option causes it to be "visually hidden" i.e, it can't be seen and hence can't be selected.
ListboxOption
The default ListboxOption should not always be selectable.
<ListboxOption value="default" label="Choose a taco">
<Taco /> Choose a taco
</ListboxOption>
The disabled prop doesn't do entire justice, the option still remains visible.
<ListboxOption value="default" disabled label="Choose a taco">
<Taco /> Choose a taco
</ListboxOption>
To achieve the display:none stuff as described on the HTML <select/> above, what I'm suggesting is to include a defaultSelectable boolean prop or use hideDisabled combined with disabled.
<ListboxOption value="default" defaultSelectable={false} label="Choose a taco">
<Taco /> Choose a taco
</ListboxOption>
or
<ListboxOption value="default" disabled hideDisabled label="Choose a taco">
<Taco /> Choose a taco
</ListboxOption>
as in — left is the normal behavior, right display the default as none.
The con is, we also get the same behavior as in the HTML <select/> element where selecting a different option causes the default <ListboxOption/> to be "visually hidden".
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Let me explain.
Typically you'd have a
<select/>
like:that renders normally with one issue: the first option (with value, state) is selectable and requires validation.
That behavior can be altered with
<option style="display: none;" value="">State</option>
. Displaying it as none makes sure that:ListboxOption
The
default
ListboxOption should not always be selectable.The
disabled
prop doesn't do entire justice, the option still remains visible.To achieve the
display:none
stuff as described on the HTML<select/>
above, what I'm suggesting is to include adefaultSelectable
boolean prop or usehideDisabled
combined withdisabled
.or
as in — left is the normal behavior, right display the default as none.
The con is, we also get the same behavior as in the HTML
<select/>
element where selecting a different option causes the default<ListboxOption/>
to be "visually hidden".Beta Was this translation helpful? Give feedback.
All reactions