Skip to content

Commit

Permalink
fix(design): correct checkbox checked state logic for standalone usage (
Browse files Browse the repository at this point in the history
  • Loading branch information
jikkai committed Mar 18, 2024
1 parent b03c707 commit 5eea109
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 5 deletions.
Expand Up @@ -74,7 +74,6 @@ export function CheckboxGroup(props: ICheckboxGroupProps) {
key: index,
children: child.props.children,
value: child.props.value,
checked: value.includes(child.props.value!),
disabled: disabled ?? child.props.disabled,
onChange: handleChange,
});
Expand Down
5 changes: 3 additions & 2 deletions packages/design/src/components/checkbox/Checkbox.tsx
Expand Up @@ -40,6 +40,7 @@ export interface ICheckboxProps {

/**
* Used for setting the currently selected value
* Only used when the checkbox is in a group
*/
value?: string | number | boolean;

Expand Down Expand Up @@ -71,8 +72,8 @@ export function Checkbox(props: ICheckboxProps) {
if (typeof value !== 'undefined') {
onChange?.(value);
} else {
const checked = inputRef?.current?.checked!;
onChange?.(!checked);
const checked = inputRef?.current?.checked ?? false;
onChange?.(checked);
}
}

Expand Down
2 changes: 0 additions & 2 deletions packages/find-replace/src/views/dialog/FindReplaceDialog.tsx
Expand Up @@ -214,7 +214,6 @@ export const ReplaceDialog = forwardRef(function ReplaceDIalogImpl(_props, ref)
<FormLayout>
<Checkbox
checked={caseSensitive}
value={caseSensitive}
onChange={(checked) => {
findReplaceService.changeCaseSensitive(checked as boolean);
}}
Expand All @@ -225,7 +224,6 @@ export const ReplaceDialog = forwardRef(function ReplaceDIalogImpl(_props, ref)
<FormLayout>
<Checkbox
checked={matchesTheWholeCell}
value={matchesTheWholeCell}
onChange={(checked) => {
findReplaceService.changeMatchesTheWholeCell(checked as boolean);
}}
Expand Down

0 comments on commit 5eea109

Please sign in to comment.