Skip to content

Commit 03bed1a

Browse files
authored
Merge pull request #61906 from thelullabyy/fix/61823-checkmark-appears-briefly
[CP Staging] Categories - Checkmark appears briefly next to the toggle after exiting selection mode
2 parents c0c6b7f + 60bdeaf commit 03bed1a

13 files changed

+24
-1
lines changed

src/components/SelectionList/BaseListItem.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ function BaseListItem<TItem extends ListItem>({
4040
hoverStyle,
4141
onLongPressRow,
4242
testID,
43+
shouldUseDefaultRightHandSideCheckmark = true,
4344
}: BaseListItemProps<TItem>) {
4445
const theme = useTheme();
4546
const styles = useThemeStyles();
@@ -125,7 +126,7 @@ function BaseListItem<TItem extends ListItem>({
125126
>
126127
{typeof children === 'function' ? children(hovered) : children}
127128

128-
{!canSelectMultiple && !!item.isSelected && !rightHandSideComponent && (
129+
{!canSelectMultiple && !!item.isSelected && !rightHandSideComponent && shouldUseDefaultRightHandSideCheckmark && (
129130
<View
130131
style={[styles.flexRow, styles.alignItemsCenter, styles.ml3]}
131132
accessible={false}

src/components/SelectionList/BaseSelectionList.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@ function BaseSelectionList<TItem extends ListItem>(
140140
fixedNumItemsForLoader,
141141
loaderSpeed,
142142
errorText,
143+
shouldUseDefaultRightHandSideCheckmark,
143144
}: SelectionListProps<TItem>,
144145
ref: ForwardedRef<SelectionListHandle>,
145146
) {
@@ -568,6 +569,7 @@ function BaseSelectionList<TItem extends ListItem>(
568569
shouldAnimateInHighlight: isItemHighlighted,
569570
...item,
570571
}}
572+
shouldUseDefaultRightHandSideCheckmark={shouldUseDefaultRightHandSideCheckmark}
571573
index={index}
572574
isFocused={isItemFocused}
573575
isDisabled={isDisabled}

src/components/SelectionList/BaseSelectionListItemRenderer.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ function BaseSelectionListItemRenderer<TItem extends ListItem>({
4343
titleStyles,
4444
singleExecution,
4545
titleContainerStyles,
46+
shouldUseDefaultRightHandSideCheckmark,
4647
}: BaseSelectionListItemRendererProps<TItem>) {
4748
const handleOnCheckboxPress = () => {
4849
if (isReportListItemType(item)) {
@@ -92,6 +93,7 @@ function BaseSelectionListItemRenderer<TItem extends ListItem>({
9293
wrapperStyle={wrapperStyle}
9394
titleStyles={titleStyles}
9495
titleContainerStyles={titleContainerStyles}
96+
shouldUseDefaultRightHandSideCheckmark={shouldUseDefaultRightHandSideCheckmark}
9597
/>
9698
{item.footerContent && item.footerContent}
9799
</>

src/components/SelectionList/TableListItem.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ function TableListItem<TItem extends ListItem>({
2727
onLongPressRow,
2828
shouldSyncFocus,
2929
titleContainerStyles,
30+
shouldUseDefaultRightHandSideCheckmark,
3031
}: TableListItemProps<TItem>) {
3132
const styles = useThemeStyles();
3233
const theme = useTheme();
@@ -80,6 +81,7 @@ function TableListItem<TItem extends ListItem>({
8081
onFocus={onFocus}
8182
shouldSyncFocus={shouldSyncFocus}
8283
hoverStyle={item.isSelected && styles.activeComponentBG}
84+
shouldUseDefaultRightHandSideCheckmark={shouldUseDefaultRightHandSideCheckmark}
8385
>
8486
{(hovered) => (
8587
<>

src/components/SelectionList/types.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -354,6 +354,9 @@ type ListItemProps<TItem extends ListItem> = CommonListItemProps<TItem> & {
354354

355355
/** Styles applied for the title container of the list item */
356356
titleContainerStyles?: StyleProp<ViewStyle>;
357+
358+
/** Whether to show the default right hand side checkmark */
359+
shouldUseDefaultRightHandSideCheckmark?: boolean;
357360
};
358361

359362
type BaseListItemProps<TItem extends ListItem> = CommonListItemProps<TItem> & {
@@ -372,6 +375,8 @@ type BaseListItemProps<TItem extends ListItem> = CommonListItemProps<TItem> & {
372375
shouldDisplayRBR?: boolean;
373376
/** Test ID of the component. Used to locate this view in end-to-end tests. */
374377
testID?: string;
378+
/** Whether to show the default right hand side checkmark */
379+
shouldUseDefaultRightHandSideCheckmark?: boolean;
375380
};
376381

377382
type UserListItemProps<TItem extends ListItem> = ListItemProps<TItem> & {
@@ -734,6 +739,9 @@ type SelectionListProps<TItem extends ListItem> = Partial<ChildrenProps> & {
734739

735740
/** Error text to display */
736741
errorText?: string;
742+
743+
/** Whether to show the default right hand side checkmark */
744+
shouldUseDefaultRightHandSideCheckmark?: boolean;
737745
} & TRightHandSideComponent<TItem>;
738746

739747
type SelectionListHandle = {

src/pages/workspace/WorkspaceMembersPage.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -798,6 +798,7 @@ function WorkspaceMembersPage({personalDetails, route, policy, currentUserPerson
798798
sections={[{data: filteredData, isDisabled: false}]}
799799
selectedItemKeys={selectedEmployees}
800800
ListItem={TableListItem}
801+
shouldUseDefaultRightHandSideCheckmark={false}
801802
turnOnSelectionModeOnLongPress={isPolicyAdmin}
802803
onTurnOnSelectionMode={(item) => item && toggleUser(item?.accountID)}
803804
shouldUseUserSkeletonView

src/pages/workspace/categories/WorkspaceCategoriesPage.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -465,6 +465,7 @@ function WorkspaceCategoriesPage({route}: WorkspaceCategoriesPageProps) {
465465
turnOnSelectionModeOnLongPress={isSmallScreenWidth}
466466
onTurnOnSelectionMode={(item) => item && toggleCategory(item)}
467467
sections={[{data: filteredCategoryList, isDisabled: false}]}
468+
shouldUseDefaultRightHandSideCheckmark={false}
468469
selectedItemKeys={selectedCategories}
469470
onCheckboxPress={toggleCategory}
470471
onSelectRow={navigateToCategorySettings}

src/pages/workspace/distanceRates/PolicyDistanceRatesPage.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -411,6 +411,7 @@ function PolicyDistanceRatesPage({
411411
turnOnSelectionModeOnLongPress
412412
onTurnOnSelectionMode={(item) => item && toggleRate(item)}
413413
sections={[{data: filteredDistanceRatesList, isDisabled: false}]}
414+
shouldUseDefaultRightHandSideCheckmark={false}
414415
selectedItemKeys={selectedDistanceRates}
415416
onCheckboxPress={toggleRate}
416417
onSelectRow={openRateDetails}

src/pages/workspace/perDiem/WorkspacePerDiemPage.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -452,6 +452,7 @@ function WorkspacePerDiemPage({route}: WorkspacePerDiemPageProps) {
452452
turnOnSelectionModeOnLongPress
453453
onTurnOnSelectionMode={(item) => item && toggleSubRate(item)}
454454
sections={[{data: filteredSubRatesList, isDisabled: false}]}
455+
shouldUseDefaultRightHandSideCheckmark={false}
455456
selectedItemKeys={selectedPerDiem.map((item) => item.subRateID)}
456457
onCheckboxPress={toggleSubRate}
457458
onSelectRow={openSubRateDetails}

src/pages/workspace/reportFields/ReportFieldsListValuesPage.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -366,6 +366,7 @@ function ReportFieldsListValuesPage({
366366
turnOnSelectionModeOnLongPress={!hasAccountingConnections}
367367
onTurnOnSelectionMode={(item) => item && toggleValue(item)}
368368
sections={sections}
369+
shouldUseDefaultRightHandSideCheckmark={false}
369370
onCheckboxPress={toggleValue}
370371
onSelectRow={openListValuePage}
371372
onSelectAll={toggleAllValues}

src/pages/workspace/tags/WorkspaceTagsPage.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -498,6 +498,7 @@ function WorkspaceTagsPage({route}: WorkspaceTagsPageProps) {
498498
turnOnSelectionModeOnLongPress={!isMultiLevelTags}
499499
onTurnOnSelectionMode={(item) => item && toggleTag(item)}
500500
sections={[{data: filteredTagList, isDisabled: false}]}
501+
shouldUseDefaultRightHandSideCheckmark={false}
501502
selectedItemKeys={selectedTags}
502503
onCheckboxPress={toggleTag}
503504
onSelectRow={navigateToTagSettings}

src/pages/workspace/tags/WorkspaceViewTagsPage.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -378,6 +378,7 @@ function WorkspaceViewTagsPage({route}: WorkspaceViewTagsProps) {
378378
turnOnSelectionModeOnLongPress
379379
onTurnOnSelectionMode={(item) => item && toggleTag(item)}
380380
sections={sections}
381+
shouldUseDefaultRightHandSideCheckmark={false}
381382
onCheckboxPress={toggleTag}
382383
onSelectRow={navigateToTagSettings}
383384
onSelectAll={toggleAllTags}

src/pages/workspace/taxes/WorkspaceTaxesPage.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -410,6 +410,7 @@ function WorkspaceTaxesPage({
410410
turnOnSelectionModeOnLongPress
411411
onTurnOnSelectionMode={(item) => item && toggleTax(item)}
412412
sections={[{data: filteredTaxesList, isDisabled: false}]}
413+
shouldUseDefaultRightHandSideCheckmark={false}
413414
selectedItemKeys={selectedTaxesIDs}
414415
onCheckboxPress={toggleTax}
415416
onSelectRow={navigateToEditTaxRate}

0 commit comments

Comments
 (0)