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

row.getIsSomeSelected returning true for row with disabled subrows #5173

Open
2 tasks done
lokalise-mark opened this issue Nov 23, 2023 · 0 comments · May be fixed by #5790
Open
2 tasks done

row.getIsSomeSelected returning true for row with disabled subrows #5173

lokalise-mark opened this issue Nov 23, 2023 · 0 comments · May be fixed by #5790

Comments

@lokalise-mark
Copy link

Describe the bug

Problem

Hi, I'm running in to an issue where row.getIsSomeSelected is returning true despite no subrows being selected. The issue appears where you have a row where all subrows are disabled. Here is an example for clarity.

Screenshot 2023-11-23 at 16 03 59

Here, I am trying to use getIsSomeSelected to determine the indeterminate state of the parent checkbox (labelled Entry: Product Links). This row contains a subrow where all children are disabled (Featured pages).

Cause

Digging through the source-code, I believe that the issue stems from recent changes to the isSubRowSelected function. This was updated in this commit and released in v8.9.10. I have confirmed that reverting to version v8.9.9 fixes the issue.

row.getIsSomeSelected makes use of the isSubRowSelected function (here) to recursively check if any descendents are selected.

The problem is that the conditions that are supposed to set allChildrenSelected to false are not executed when:

  1. The row is disabled
  2. The row does no have further subrows

As in this case we have a disabled parent with four disabled children, neither condition can be triggered. This leads to allChildrenSelected remaining true throughout and isSubRowSelected then returning true itself.

Your minimal, reproducible example

https://codesandbox.io/p/sandbox/snowy-silence-mznd62?file=%2Fsrc%2Findex.tsx%3A152%2C19&layout=%257B%2522sidebarPanel%2522%253A%2522EXPLORER%2522%252C%2522rootPanelGroup%2522%253A%257B%2522direction%2522%253A%2522horizontal%2522%252C%2522contentType%2522%253A%2522UNKNOWN%2522%252C%2522type%2522%253A%2522PANEL_GROUP%2522%252C%2522id%2522%253A%2522ROOT_LAYOUT%2522%252C%2522panels%2522%253A%255B%257B%2522type%2522%253A%2522PANEL_GROUP%2522%252C%2522contentType%2522%253A%2522UNKNOWN%2522%252C%2522direction%2522%253A%2522vertical%2522%252C%2522id%2522%253A%2522clpbktpo300073b6hm8x4qp8z%2522%252C%2522sizes%2522%253A%255B70%252C30%255D%252C%2522panels%2522%253A%255B%257B%2522type%2522%253A%2522PANEL_GROUP%2522%252C%2522contentType%2522%253A%2522EDITOR%2522%252C%2522direction%2522%253A%2522horizontal%2522%252C%2522id%2522%253A%2522EDITOR%2522%252C%2522panels%2522%253A%255B%257B%2522type%2522%253A%2522PANEL%2522%252C%2522contentType%2522%253A%2522EDITOR%2522%252C%2522id%2522%253A%2522clpbktpo300033b6hnm6jbjw7%2522%257D%255D%257D%252C%257B%2522type%2522%253A%2522PANEL_GROUP%2522%252C%2522contentType%2522%253A%2522SHELLS%2522%252C%2522direction%2522%253A%2522horizontal%2522%252C%2522id%2522%253A%2522SHELLS%2522%252C%2522panels%2522%253A%255B%257B%2522type%2522%253A%2522PANEL%2522%252C%2522contentType%2522%253A%2522SHELLS%2522%252C%2522id%2522%253A%2522clpbktpo300043b6haqq7ppek%2522%257D%255D%252C%2522sizes%2522%253A%255B100%255D%257D%255D%257D%252C%257B%2522type%2522%253A%2522PANEL_GROUP%2522%252C%2522contentType%2522%253A%2522DEVTOOLS%2522%252C%2522direction%2522%253A%2522vertical%2522%252C%2522id%2522%253A%2522DEVTOOLS%2522%252C%2522panels%2522%253A%255B%257B%2522type%2522%253A%2522PANEL%2522%252C%2522contentType%2522%253A%2522DEVTOOLS%2522%252C%2522id%2522%253A%2522clpbktpo300063b6hb49kmgk1%2522%257D%255D%252C%2522sizes%2522%253A%255B100%255D%257D%255D%252C%2522sizes%2522%253A%255B72.62965349408113%252C27.370346505918874%255D%257D%252C%2522tabbedPanels%2522%253A%257B%2522clpbktpo300033b6hnm6jbjw7%2522%253A%257B%2522id%2522%253A%2522clpbktpo300033b6hnm6jbjw7%2522%252C%2522activeTabId%2522%253A%2522clpbl6vgq00up3b6h9t4pi34d%2522%252C%2522tabs%2522%253A%255B%257B%2522type%2522%253A%2522FILE%2522%252C%2522filepath%2522%253A%2522%252Fsrc%252Findex.tsx%2522%252C%2522initialSelections%2522%253A%255B%257B%2522startLineNumber%2522%253A152%252C%2522startColumn%2522%253A19%252C%2522endLineNumber%2522%253A152%252C%2522endColumn%2522%253A19%257D%255D%252C%2522id%2522%253A%2522clpbl6vgq00up3b6h9t4pi34d%2522%252C%2522mode%2522%253A%2522temporary%2522%252C%2522state%2522%253A%2522IDLE%2522%257D%255D%257D%252C%2522clpbktpo300063b6hb49kmgk1%2522%253A%257B%2522tabs%2522%253A%255B%257B%2522id%2522%253A%2522clpbktpo300053b6hc67gynaa%2522%252C%2522mode%2522%253A%2522permanent%2522%252C%2522type%2522%253A%2522UNASSIGNED_PORT%2522%252C%2522port%2522%253A0%252C%2522path%2522%253A%2522%2522%257D%255D%252C%2522id%2522%253A%2522clpbktpo300063b6hb49kmgk1%2522%252C%2522activeTabId%2522%253A%2522clpbktpo300053b6hc67gynaa%2522%257D%252C%2522clpbktpo300043b6haqq7ppek%2522%253A%257B%2522tabs%2522%253A%255B%255D%252C%2522id%2522%253A%2522clpbktpo300043b6haqq7ppek%2522%257D%257D%252C%2522showDevtools%2522%253Atrue%252C%2522showShells%2522%253Atrue%252C%2522showSidebar%2522%253Atrue%252C%2522sidebarPanelSize%2522%253A15%257D

Steps to reproduce

  1. Instantiate a table with a subrow containing only disabled entries
  2. Check the result of row.getIsSomeSelected for the parent row
  3. See that it returns true even when no subrows are selected/selectable

Expected behavior

row.getIsSomeSelected returns false

How often does this bug happen?

Every time

Screenshots or Videos

No response

Platform

MacOS, Chrome

react-table version

8.10.7

TypeScript version

5.2.2

Additional context

No response

Terms & Code of Conduct

  • I agree to follow this project's Code of Conduct
  • I understand that if my bug cannot be reliable reproduced in a debuggable environment, it will probably not be fixed and this issue may even be closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant