Fix checkbox htmlfor bug (#2315)

fix bug
This commit is contained in:
bosiraphael
2023-11-02 14:05:47 +01:00
committed by GitHub
parent 27b451ee56
commit 316f2df170

View File

@ -1,5 +1,6 @@
import * as React from 'react';
import styled from '@emotion/styled';
import { v4 } from 'uuid';
import { IconCheck, IconMinus } from '@/ui/display/icon';
@ -130,11 +131,14 @@ export const Checkbox = ({
setIsInternalChecked(event.target.checked);
};
const checkboxId = 'checkbox' + v4();
return (
<StyledInputContainer>
<StyledInput
autoComplete="off"
type="checkbox"
id={checkboxId}
name="styled-checkbox"
data-testid="input-checkbox"
checked={isInternalChecked}
@ -145,7 +149,7 @@ export const Checkbox = ({
isChecked={isInternalChecked}
onChange={handleChange}
/>
<label htmlFor="checkbox">
<label htmlFor={checkboxId}>
{indeterminate ? (
<IconMinus />
) : isInternalChecked ? (