Skip to content

Commit a9718ca

Browse files
authored
Merge pull request Expensify#64462 from software-mansion-labs/fix/select-all-checkbox-marked-after-deleting-all-expenses-in-offline
Fix "Select all" checkbox is still marked after deleting all the expenses in offline mode
2 parents f99dbdc + 0566194 commit a9718ca

3 files changed

Lines changed: 9 additions & 6 deletions

File tree

src/components/MoneyRequestReportView/MoneyRequestReportActionsList.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -532,6 +532,8 @@ function MoneyRequestReportActionsList({
532532
// Parse Fullstory attributes on initial render
533533
useLayoutEffect(parseFSAttributes, []);
534534

535+
const isSelectAllChecked = selectedTransactionIDs.length > 0 && selectedTransactionIDs.length === transactionsWithoutPendingDelete.length;
536+
535537
return (
536538
<View
537539
style={[styles.flex1]}
@@ -550,7 +552,7 @@ function MoneyRequestReportActionsList({
550552
<View style={[styles.alignItemsCenter, styles.userSelectNone, styles.flexRow, styles.pt6, styles.ph8]}>
551553
<Checkbox
552554
accessibilityLabel={translate('workspace.people.selectAll')}
553-
isChecked={selectedTransactionIDs.length === transactionsWithoutPendingDelete.length}
555+
isChecked={isSelectAllChecked}
554556
isIndeterminate={selectedTransactionIDs.length > 0 && selectedTransactionIDs.length !== transactionsWithoutPendingDelete.length}
555557
onPress={() => {
556558
if (selectedTransactionIDs.length !== 0) {
@@ -563,15 +565,15 @@ function MoneyRequestReportActionsList({
563565
<PressableWithFeedback
564566
style={[styles.userSelectNone, styles.alignItemsCenter]}
565567
onPress={() => {
566-
if (selectedTransactionIDs.length === transactions.length) {
568+
if (isSelectAllChecked) {
567569
clearSelectedTransactions(true);
568570
} else {
569571
setSelectedTransactions(transactionsWithoutPendingDelete.map((t) => t.transactionID));
570572
}
571573
}}
572574
accessibilityLabel={translate('workspace.people.selectAll')}
573575
role="button"
574-
accessibilityState={{checked: selectedTransactionIDs.length === transactions.length}}
576+
accessibilityState={{checked: isSelectAllChecked}}
575577
dataSet={{[CONST.SELECTION_SCRAPER_HIDDEN_ELEMENT]: true}}
576578
>
577579
<Text style={[styles.textStrong, styles.ph3]}>{translate('workspace.people.selectAll')}</Text>

src/components/MoneyRequestReportView/MoneyRequestReportTransactionList.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ function MoneyRequestReportTransactionList({
238238
}}
239239
accessibilityLabel={CONST.ROLE.CHECKBOX}
240240
isIndeterminate={selectedTransactionIDs.length > 0 && selectedTransactionIDs.length !== transactionsWithoutPendingDelete.length}
241-
isChecked={selectedTransactionIDs.length === transactionsWithoutPendingDelete.length}
241+
isChecked={selectedTransactionIDs.length > 0 && selectedTransactionIDs.length === transactionsWithoutPendingDelete.length}
242242
/>
243243
{isMediumScreenWidth && <Text style={[styles.textStrong, styles.ph3]}>{translate('workspace.people.selectAll')}</Text>}
244244
</View>

src/components/Search/SearchList.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -361,6 +361,7 @@ function SearchList(
361361

362362
const tableHeaderVisible = canSelectMultiple || !!SearchTableHeader;
363363
const selectAllButtonVisible = canSelectMultiple && !SearchTableHeader;
364+
const isSelectAllChecked = selectedItemsLength > 0 && selectedItemsLength === flattenedTransactionWithoutPendingDelete.length;
364365

365366
return (
366367
<View style={[styles.flex1, !isKeyboardShown && safeAreaPaddingBottomStyle, containerStyle]}>
@@ -369,7 +370,7 @@ function SearchList(
369370
{canSelectMultiple && (
370371
<Checkbox
371372
accessibilityLabel={translate('workspace.people.selectAll')}
372-
isChecked={flattenedTransactionWithoutPendingDelete.length > 0 && selectedItemsLength === flattenedTransactionWithoutPendingDelete.length}
373+
isChecked={isSelectAllChecked}
373374
isIndeterminate={selectedItemsLength > 0 && selectedItemsLength !== flattenedTransactionWithoutPendingDelete.length}
374375
onPress={() => {
375376
onAllCheckboxPress();
@@ -386,7 +387,7 @@ function SearchList(
386387
onPress={onAllCheckboxPress}
387388
accessibilityLabel={translate('workspace.people.selectAll')}
388389
role="button"
389-
accessibilityState={{checked: selectedItemsLength === flattenedTransactionWithoutPendingDelete.length}}
390+
accessibilityState={{checked: isSelectAllChecked}}
390391
dataSet={{[CONST.SELECTION_SCRAPER_HIDDEN_ELEMENT]: true}}
391392
>
392393
<Text style={[styles.textStrong, styles.ph3]}>{translate('workspace.people.selectAll')}</Text>

0 commit comments

Comments
 (0)