Fix category and checkbox onChange event handling

This commit is contained in:
Simon Larsen 2023-12-18 22:01:37 +00:00
parent e51c3c5c56
commit 37d2d8bedf
No known key found for this signature in database
GPG Key ID: AB45983AA9C81CDE
2 changed files with 6 additions and 7 deletions

View File

@ -56,9 +56,9 @@ const Category: FunctionComponent<CategoryProps> = (
setCategoryCheckboxState(CategoryCheckboxValueState.Indeterminate);
}
props.onChange(currentValues);
}, [currentValues]);
return (
<div>
{props.category && (

View File

@ -39,12 +39,6 @@ const CheckboxElement: FunctionComponent<CategoryProps> = (
setValue(props.value || false);
}, [props.value]);
React.useEffect(() => {
if (props.onChange) {
props.onChange(value, props.isIndeterminate);
}
}, [value]);
return (
<div>
<div
@ -59,6 +53,11 @@ const CheckboxElement: FunctionComponent<CategoryProps> = (
event: React.ChangeEvent<HTMLInputElement>
) => {
setValue(event.target.checked);
if (props.onChange) {
props.onChange(event.target.checked, props.isIndeterminate);
}
}}
ref={checkboxRef}
autoFocus={props.autoFocus}