`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](https://private-user-images.githubusercontent.com/2828721/286271381-b4ea87ff-f3ed-4c2e-a2b6-7705abd8d18e.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjQ3MzkyMjIsIm5iZiI6MTcyNDczODkyMiwicGF0aCI6Ii8yODI4NzIxLzI4NjI3MTM4MS1iNGVhODdmZi1mM2VkLTRjMmUtYTJiNi03NzA1YWJkOGQxOGUucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI0MDgyNyUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNDA4MjdUMDYwODQyWiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9YmIzNTIwZmM2MmU5MGFkOWRiYjBjODdkMWJmNTZkMTFmOTRiN2QzZDlmZjgwODNkZjIzNjE2MTE1ODE3MThiOCZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QmYWN0b3JfaWQ9MCZrZXlfaWQ9MCZyZXBvX2lkPTAifQ._fsmTmknKyifqcNo8ZvQBgk4i6ho47wwYRT_Kf-2_10)
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](https://private-user-images.githubusercontent.com/2828721/286274841-b6df8eda-1cb0-427e-8c58-28319397d345.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjQ3MzkyMjIsIm5iZiI6MTcyNDczODkyMiwicGF0aCI6Ii8yODI4NzIxLzI4NjI3NDg0MS1iNmRmOGVkYS0xY2IwLTQyN2UtOGM1OC0yODMxOTM5N2QzNDUucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI0MDgyNyUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNDA4MjdUMDYwODQyWiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9ZTczOTRlZDRlZmZiYmU3ZWQ0ZmRkY2RmNDFlMDUzMTVkNzM2ZDNkNGU1MmJjNmQwMDc3MjQ0YTRjODU4MjE1YiZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QmYWN0b3JfaWQ9MCZrZXlfaWQ9MCZyZXBvX2lkPTAifQ.xIPGsuBjnPR68Znp2OjVVljnjsLlkkiEAaYsdXzELvE)
PR: #2929