Implement labelFor on label filters so the whole area can be clicked

This commit is contained in:
Jackson Harper 2023-03-06 12:39:41 +08:00
parent 8a27a50eb5
commit 6df0780244

View file

@ -286,6 +286,7 @@ type LabelButtonProps = {
}
function LabelButton(props: LabelButtonProps): JSX.Element {
const labelId = `checkbox-label-${props.label.id}`
const state = useMemo(() => {
const term = props.searchTerm ?? ''
if (term.indexOf(`label:\"${props.label.name}\"`) >= 0) {
@ -316,14 +317,17 @@ function LabelButton(props: LabelButtonProps): JSX.Element {
alignment="center"
distribution="start"
>
<Circle size={9} color={props.label.color} weight="fill" />
<SpanBox css={{ pl: '10px' }}>{props.label.name}</SpanBox>
<label htmlFor={labelId} style={{ width: '100%' }}>
<Circle size={9} color={props.label.color} weight="fill" />
<SpanBox css={{ pl: '10px' }}>{props.label.name}</SpanBox>
</label>
<SpanBox
css={{
ml: 'auto',
}}
>
<input
id={labelId}
type="checkbox"
checked={state === 'on'}
onChange={(e) => {