mirror of
https://github.com/CommunityOx/ox_lib.git
synced 2026-08-17 06:56:03 +01:00
fix(web/dialog): setting non-selectable placeholder (#67)
* tweak(interface/menu): SetNuiFocusKeepInput Default to allow input; disable with "disableInput = false" during registration. * fix(web/dialog): Setting non-selectable placeholder React doesn't like the 'selected' attribute (causing a warning in web console - not in-game). 'defaultValue' should be used instead so there is no need to create placeholder option if 'defaultValue' is already defined by row options. * fix(web/dialog): Use proper type for onChange event Co-authored-by: Linden <65407488+thelindat@users.noreply.github.com>
This commit is contained in:
@@ -23,16 +23,16 @@ const SelectField: React.FC<Props> = (props) => {
|
||||
<>
|
||||
<Box mb={3} key={`select-${props.index}`}>
|
||||
<Select
|
||||
onChange={(e) => props.handleChange(e.target.value, props.index)}
|
||||
defaultValue={props.row.default}
|
||||
onChange={(e: React.ChangeEvent<HTMLSelectElement>) => props.handleChange(e.target.value, props.index)}
|
||||
defaultValue={props.row.default || ""}
|
||||
>
|
||||
{/* Hacky workaround for selectable placeholder issue */}
|
||||
<option value="" selected hidden disabled>
|
||||
{!props.row.default && (<option value="" hidden disabled>
|
||||
{props.row.label}
|
||||
</option>
|
||||
</option>)}
|
||||
{props.row.options?.map((option, index) => (
|
||||
<option key={`option-${index}`} value={option.value}>
|
||||
{option.label ? option.label : option.value}
|
||||
{option.label || option.value}
|
||||
</option>
|
||||
))}
|
||||
</Select>
|
||||
|
||||
Reference in New Issue
Block a user