Skip to content

Commit

Permalink
fix(Checkbox): fix checkboxGroup onChange context option param
Browse files Browse the repository at this point in the history
  • Loading branch information
HaixingOoO authored Jan 29, 2025
1 parent 262cce9 commit f259082
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/checkbox/CheckboxGroup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -138,11 +138,14 @@ const CheckboxGroup = <T extends CheckboxGroupValue = CheckboxGroupValue>(props:
checkedSet.delete(checkValue);
}

const currentOptionChecked = optionsWithoutCheckAll.find((item) => item.value === checkValue);

// 此处 `as` 是因为 `Array.from` 会导致 `checkSet` 的 generic type 丢失
setInternalValue(Array.from(checkedSet) as T, {
e,
current: checkProps.checkAll ? undefined : (checkValue as TdCheckboxProps),
type: checked ? 'check' : 'uncheck',
option: checkProps.checkAll ? undefined : currentOptionChecked,
});
},
};
Expand Down
1 change: 1 addition & 0 deletions src/checkbox/type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,5 +118,6 @@ export type CheckboxGroupValue = Array<string | number | boolean>;
export interface CheckboxGroupChangeContext {
e: ChangeEvent<HTMLDivElement>;
current: CheckboxOption | TdCheckboxProps;
option: CheckboxOption | TdCheckboxProps;
type: 'check' | 'uncheck';
}

0 comments on commit f259082

Please sign in to comment.