Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix onCheck checked state #1697

Merged
merged 1 commit into from
Feb 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/components/Renderer/__snapshots__/spec.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -1605,11 +1605,11 @@ exports[`Renderer component A drop-down button widget 1`] = `
data-prefix="fas"
focusable="false"
role="img"
viewBox="0 0 512 512"
viewBox="0 0 448 512"
xmlns="http://www.w3.org/2000/svg"
>
<path
d="M233.4 406.6c12.5 12.5 32.8 12.5 45.3 0l192-192c12.5-12.5 12.5-32.8 0-45.3s-32.8-12.5-45.3 0L256 338.7 86.6 169.4c-12.5-12.5-32.8-12.5-45.3 0s-12.5 32.8 0 45.3l192 192z"
d="M201.4 406.6c12.5 12.5 32.8 12.5 45.3 0l192-192c12.5-12.5 12.5-32.8 0-45.3s-32.8-12.5-45.3 0L224 338.7 54.6 169.4c-12.5-12.5-32.8-12.5-45.3 0s-12.5 32.8 0 45.3l192 192z"
fill="currentColor"
/>
</svg>
Expand Down Expand Up @@ -4058,7 +4058,7 @@ exports[`Renderer component An invalid value 1`] = `
xmlns="http://www.w3.org/2000/svg"
>
<path
d="M367.2 412.5L99.5 144.8C77.1 176.1 64 214.5 64 256c0 106 86 192 192 192c41.5 0 79.9-13.1 111.2-35.5zm45.3-45.3C434.9 335.9 448 297.5 448 256c0-106-86-192-192-192c-41.5 0-79.9 13.1-111.2 35.5L412.5 367.2zM512 256c0 141.4-114.6 256-256 256S0 397.4 0 256S114.6 0 256 0S512 114.6 512 256z"
d="M367.2 412.5L99.5 144.8C77.1 176.1 64 214.5 64 256c0 106 86 192 192 192c41.5 0 79.9-13.1 111.2-35.5zm45.3-45.3C434.9 335.9 448 297.5 448 256c0-106-86-192-192-192c-41.5 0-79.9 13.1-111.2 35.5L412.5 367.2zM0 256a256 256 0 1 1 512 0A256 256 0 1 1 0 256z"
fill="currentColor"
/>
</svg>
Expand Down
19 changes: 10 additions & 9 deletions src/components/Table/TableBase.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -413,17 +413,18 @@ export class TableBase<T extends {}> extends React.Component<
? data.filter((r) => !disabledRowsSet.has(r[rowKey]))
: data.slice();
}
if (onCheck) {
onCheck(checkedItems, this.state.checkedState);
}

this.setState(({ checkedState }) => ({
lastSelected: null,
checkedState: pagination?.serverSide
this.setState(({ checkedState }) => {
const newCheckedState = pagination?.serverSide
? this.toggleCheckedState(checkedState)
: this.howManyRowsChecked(checkedItems!),
checkedItems,
}));
: this.howManyRowsChecked(checkedItems!);
onCheck?.(checkedItems, newCheckedState);
return {
lastSelected: null,
checkedState: newCheckedState,
checkedItems,
};
});
};

public toggleChecked = (e: React.ChangeEvent<HTMLInputElement>) => {
Expand Down