Skip to content

Commit

Permalink
[Discover] Improve a little
Browse files Browse the repository at this point in the history
  • Loading branch information
jughosta committed Jul 30, 2024
1 parent f123193 commit de39fc4
Showing 1 changed file with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -177,13 +177,16 @@ export function DataTableDocumentToolbarBtn({
getCountOfSelectedDocs,
} = selectedDocsState;

const areAllDocsOnCurrentPageSelected = () => {
const shouldSuggestToSelectAll = useMemo(() => {
if (isFilterActive || !(selectedDocIds.length < rows.length && rows.length > 1)) {
return false;
}
const docIdsFromCurrentPage = getDocIdsForCurrentPage(rows, pageIndex, pageSize);
if (!docIdsFromCurrentPage?.length) {
return false;
}
return getCountOfSelectedDocs(docIdsFromCurrentPage) === pageSize;
};
return getCountOfSelectedDocs(docIdsFromCurrentPage) === docIdsFromCurrentPage.length;
}, [getCountOfSelectedDocs, rows, pageIndex, pageSize, selectedDocIds.length, isFilterActive]);

const getMenuItems = useCallback(() => {
return [
Expand Down Expand Up @@ -358,10 +361,7 @@ export function DataTableDocumentToolbarBtn({
<EuiFlexItem className="unifiedDataTableToolbarControlButton" grow={false}>
{selectedRowsMenuButton}
</EuiFlexItem>
{!isFilterActive &&
selectedDocIds.length < rows.length &&
rows.length > 1 &&
areAllDocsOnCurrentPageSelected() ? (
{shouldSuggestToSelectAll ? (
<EuiFlexItem className="unifiedDataTableToolbarControlButton" grow={false}>
<EuiDataGridToolbarControl
data-test-subj="dscGridSelectAllDocs"
Expand Down

0 comments on commit de39fc4

Please sign in to comment.