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 : "")}
|
||||
onChange={(e) => update(items, onChange, e)}
|
||||
className={className}
|
||||
defaultValue={current}
|
||||
>
|
||||
{items.map(({ label, value }, index) => (
|
||||
<option
|
||||
data-testid={"option-" + (testId ? testId + "-" : "") + index}
|
||||
key={[label, index].join("")}
|
||||
value={value.toString()}
|
||||
>
|
||||
{label}
|
||||
</option>
|
||||
))}
|
||||
{items.map(({ label, value }, index) => {
|
||||
if (label === current) {(
|
||||
<option
|
||||
data-testid={"option-" + (testId ? testId + "-" : "") + index}
|
||||
key={[label, index].join("")}
|
||||
value={value.toString()}
|
||||
selected
|
||||
>
|
||||
{label}
|
||||
</option>
|
||||
)} else {(
|
||||
<option
|
||||
data-testid={"option-" + (testId ? testId + "-" : "") + index}
|
||||
key={[label, index].join("")}
|
||||
value={value.toString()}
|
||||
>
|
||||
{label}
|
||||
</option>
|
||||
)}
|
||||
})}
|
||||
</select>
|
||||
);
|
||||
|
||||
|
|
Loading…
Reference in a new issue