Switching from select defaultValue to option selected.

This commit is contained in:
cinderblockgames 2021-11-18 22:25:28 -05:00
parent 6288a02b50
commit 4ba197354e

View file

@ -32,17 +32,27 @@ const Select = ({
data-testid={"select" + (testId ? "-" + testId : "")} data-testid={"select" + (testId ? "-" + testId : "")}
onChange={(e) => update(items, onChange, e)} onChange={(e) => update(items, onChange, e)}
className={className} className={className}
defaultValue={current}
> >
{items.map(({ label, value }, index) => ( {items.map(({ label, value }, index) => {
<option if (label === current) {(
data-testid={"option-" + (testId ? testId + "-" : "") + index} <option
key={[label, index].join("")} data-testid={"option-" + (testId ? testId + "-" : "") + index}
value={value.toString()} key={[label, index].join("")}
> value={value.toString()}
{label} selected
</option> >
))} {label}
</option>
)} else {(
<option
data-testid={"option-" + (testId ? testId + "-" : "") + index}
key={[label, index].join("")}
value={value.toString()}
>
{label}
</option>
)}
})}
</select> </select>
); );