Skip to content

strange select behavior when using useExpanded and useRowSelect #3106

Closed

Description

@adsee42

Describe the bug (required)
See the screenshot below

Provide an example via Codesandbox! (required)
https://codesandbox.io/s/nervous-shaw-fqy2x

Steps To Reproduce (required)
Steps to reproduce the behavior:

  1. Expand the only top level row
  2. Select all its children
  3. See error

Expected behavior (Recommended)
The "select all" checkbox is expected to be selected.

Screenshots
image

Activity

  1. dnquang1996vn commented on May 17, 2021

    @dnquang1996vn

    The issue is like that:
    Steps To Reproduce (required)

    • select a parent row => all the children rows will be selected
    • toggle select children rows => the selection of parent row does not change => error

    Expected behavior

    • when toggling children rows, It affects to the selection of parent row also
  2. dnquang1996vn commented on May 20, 2021

    @dnquang1996vn

    the solution for it add
    function getAllParentId(id) { const array = id.split('.'); const parents = []; while (array && array.length > 1) { array.pop(); parents.push(array.join('.')); } return parents; }

    `    const parentIds = getAllParentId(id);
    if (!shouldExist) {
      parentIds.forEach((i) => delete newSelectedRowIds[i]);
    }`
    
    
    
    to the reducer handle `action.type === actions.toggleRowSelected` in hook `useRowSelect`. 
    
  3. dnquang1996vn commented on May 20, 2021

    @dnquang1996vn

    here is the solution https://codesandbox.io/s/nifty-matsumoto-to2sx?file=/src/App.js
    need a PR to fix it.

  4. github-actions commented on Apr 8, 2022

    @github-actions
    Contributor

    This issue is being marked as stale (no activity in the last 14 days)

  5. github-actions commented on Apr 8, 2022

    @github-actions
    Contributor

    This issue has been detected as stale and automatically closed. It's very likely that your issue has remained here this long because it would require breaking changes to v7. React Table v8 is currently in alpha (soon beta!) and already contains bug fixes, performance improvements and architectural changes that likely address this issue.

    • If your v7 issue has been previously labeled as requiring breaking changes, please try the new v8 alpha/beta releases
    • If your v7 issue has not already been labeled as a breaking change, open a new issue.
    • If this was a v8 issue and was closed by mistake, please reopen or leave a comment below.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions