Switching from select defaultValue
to option selected
.
This commit is contained in:
parent
6288a02b50
commit
4ba197354e
1 changed files with 20 additions and 10 deletions
|
@ -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>
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue