Skip to content

Commit 2b5298d

Browse files
MelvinBotbernhardoj
andcommitted
Hide total footer bar when "Select all matching items" is active
The total footer was still showing when "Select all matching items" was clicked because shouldShowFooter never checked areAllMatchingItemsSelected. Also remove the dead-code disjunct in shouldUseClientTotal that was fully absorbed by an earlier branch. Co-authored-by: Bernhard Owen Josephus <bernhardoj@users.noreply.github.com>
1 parent 1dd01da commit 2b5298d

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

src/pages/Search/SearchPage.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ function SearchPage({route}: SearchPageProps) {
6565

6666
const metadata = searchResults?.search;
6767
const shouldAllowFooterTotals = useSearchShouldCalculateTotals(currentSearchKey, currentSearchQueryJSON?.hash, true);
68-
const shouldShowFooter = selectedTransactionsKeys.length > 0 || (shouldAllowFooterTotals && !!metadata?.count);
68+
const shouldShowFooter = !areAllMatchingItemsSelected && (selectedTransactionsKeys.length > 0 || (shouldAllowFooterTotals && !!metadata?.count));
6969

7070
useEffect(() => {
7171
if (shouldUseNarrowLayout) {
@@ -109,7 +109,7 @@ function SearchPage({route}: SearchPageProps) {
109109
return {count: undefined, total: undefined, currency: undefined};
110110
}
111111

112-
const shouldUseClientTotal = selectedTransactionsKeys.length > 0 || !metadata?.count || (selectedTransactionsKeys.length > 0 && !areAllMatchingItemsSelected);
112+
const shouldUseClientTotal = selectedTransactionsKeys.length > 0 || !metadata?.count;
113113
const selectedTransactionItems = Object.values(selectedTransactions);
114114
const currency = metadata?.currency ?? selectedTransactionItems.at(0)?.groupCurrency ?? selectedTransactionItems.at(0)?.currency;
115115
const numberOfExpense = shouldUseClientTotal
@@ -124,7 +124,7 @@ function SearchPage({route}: SearchPageProps) {
124124
const total = shouldUseClientTotal ? selectedTransactionItems.reduce((acc, transaction) => acc - (transaction.groupAmount ?? -Math.abs(transaction.amount)), 0) : metadata?.total;
125125

126126
return {count: numberOfExpense, total, currency};
127-
}, [areAllMatchingItemsSelected, metadata?.count, metadata?.currency, metadata?.total, selectedTransactions, selectedTransactionsKeys, shouldAllowFooterTotals]);
127+
}, [metadata?.count, metadata?.currency, metadata?.total, selectedTransactions, selectedTransactionsKeys, shouldAllowFooterTotals]);
128128

129129
const onSortPressedCallback = useCallback(() => {
130130
setIsSorting(true);

0 commit comments

Comments
 (0)