T
TanStack2y ago
plain-purple

Row Index 0 can't be selected

Does anyone encounter this problem? If so, can you tell me what did you do to resolve this bug
No description
5 Replies
helpful-purple
helpful-purple2y ago
I have never encountered this. You probably have some "truthy" bug where you're reading the index/key instead of the selection state instead of the value
plain-purple
plain-purpleOP2y ago
I use row.getIsSelected() to check if the row is selected
<Checkbox
checked={row.getIsSelected()}
onCheckedChange={(value) => {
row.toggleSelected(!!value);

value
? setSelectedOrder!((prev) => [...prev, { index: row.index, order: row.original }])
: setSelectedOrder!((prev) => prev.filter((order) => order.index !== row.index));
}}
disabled={!handleFilter(maxWeight, table, row)}
aria-label="Select row"
/>
<Checkbox
checked={row.getIsSelected()}
onCheckedChange={(value) => {
row.toggleSelected(!!value);

value
? setSelectedOrder!((prev) => [...prev, { index: row.index, order: row.original }])
: setSelectedOrder!((prev) => prev.filter((order) => order.index !== row.index));
}}
disabled={!handleFilter(maxWeight, table, row)}
aria-label="Select row"
/>
helpful-purple
helpful-purple2y ago
Have you verified that the row selection state is correct? Is this a bug showing selection state or selecting the rows in the first place?
plain-purple
plain-purpleOP2y ago
It turns out that the row is being selected, but after it is selected, the row selection is being reset.
No description
helpful-purple
helpful-purple2y ago
probably a problem with your onCheckedChange function. Looks a bit sketch wit the value thing and multiple selection states

Did you find this page helpful?