gregnb / gregnb/mui-datatables

onRowSelectionChange Returns Inconsistent Arrays Depending on Selection

Open
#1,505 1 comment 1 reaction 0 assignees View on GitHub
Dominant language
JavaScript
Stars
2.7k
Forks
906
PR merge metrics
No merged PRs in 30d

Description

The three arrays currentRowsSelected, allRowsSelected and rowsSelected that get returned from the onRowSelectionChange consist of a list of indexes when selecting one or several rows but consists of all the data (not just the indexes) when selecting all via the "select all" checkbox in the header.

## Expected Behavior

The arrays should return a list of indexes just like when selecting one or multiple rows when selecting all via the "select all" chexbox from the header.

## Current Behavior

The arrays return all the data from the rows.

## Steps to Reproduce (for bugs)

1. Fill a datatable and set the selectableRows option to "multiple"
2. Use onRowSelectionChange to return the rowsSelected
3. Select one or two lines and see the return in the form of an array with elements {dataIndex, index}
4. Select all lines with the "select multiple" checkbox from the header and see the return in the form of an array of whatever data provided

## Your Environment

| Tech | Version |
|--------------|---------|
| Material-UI | 4.11.0 |
| MUI-datatables | 3.4.1 |
| React | 16.13.1 |
| browser | 84.0.4147.135 |

Contributor guide

No contributing guide indexed for this repository

Research direction

Start at the onRowSelectionChange selection-handling entry point and reproduce the reported difference between selecting individual rows and using the header select-all checkbox. Trace the values assigned to currentRowsSelected, allRowsSelected, and rowsSelected. Done means all three arrays consistently contain row indexes in both selection paths.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, react
Domain
frontend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.