openedx / paragon

💎 An accessible, theme-ready design system built for learning applications and Open edX.

Home Page:https://paragon-openedx.netlify.app

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

`DataTable`'s "Select all..." label in `BaseSelectionStatus` shows incorrect counts

adamstankiewicz opened this issue · comments

Bugs

There appears to be a bug/regression related to DataTable and the "Select all" label in the BaseSelectionStatus component, introduced by this PR, which seemed to separately resolve a different bug.

As seen on the Paragon documentation site, when selecting a row using the DataTable.ControlledSelect* sub-components, the "Select all..." label incorrectly says "Select all 3" when there are 7 rows total.

image

I believe the issue is related to this line:

const filteredItems = filteredRows?.length || itemCount;

It appears that even without any filters applied, filteredRows comes back with an array containing the rows for current page, preventing the itemCount from being shown.

Adjusting the logic to include hasAppliedFilters resolves this particular issue:

const filteredItems = (hasAppliedFilters && filteredRows?.length) || itemCount;

However, it does appear that when a filter is applied, the "Select all..." count is still not quite correct when using the DataTable.ControlledSelect* components. For example, this below table has 60 rows total without any filters ("Select all 60" ✅ ); with a filter applied for "Status" column, there are now 55 rows total (itemCount) but it would state "Select all 25" ⛔ (since the visible page has 25 rows):

image

Tasks