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:
ANTOND
2022-08-09 23:37:31 +02:00
committed by GitHub
parent c3726ed924
commit de8fb447a9

View File

@@ -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>