Skip to content

Commit 2608780

Browse files
fix: hide product tooltip when navigate to other tab
1 parent 045eda9 commit 2608780

5 files changed

Lines changed: 30 additions & 5 deletions

File tree

src/components/SelectionList/BaseSelectionList.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,7 @@ function BaseSelectionList<TItem extends ListItem>(
147147
shouldUseDefaultRightHandSideCheckmark,
148148
selectedItems = [],
149149
isSelected,
150+
canShowProductTrainingTooltip,
150151
}: SelectionListProps<TItem>,
151152
ref: ForwardedRef<SelectionListHandle>,
152153
) {
@@ -190,6 +191,10 @@ function BaseSelectionList<TItem extends ListItem>(
190191
[isSelected, selectedItems, canSelectMultiple],
191192
);
192193

194+
const canShowProductTrainingTooltipMemo = useMemo(() => {
195+
return canShowProductTrainingTooltip && isFocused;
196+
}, [canShowProductTrainingTooltip, isFocused]);
197+
193198
/**
194199
* Iterates through the sections and items inside each section, and builds 4 arrays along the way:
195200
* - `allOptions`: Contains all the items in the list, flattened, regardless of section
@@ -618,6 +623,7 @@ function BaseSelectionList<TItem extends ListItem>(
618623
titleStyles={listItemTitleStyles}
619624
singleExecution={singleExecution}
620625
titleContainerStyles={listItemTitleContainerStyles}
626+
canShowProductTrainingTooltip={canShowProductTrainingTooltipMemo}
621627
/>
622628
</View>
623629
);

src/components/SelectionList/BaseSelectionListItemRenderer.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import {isTransactionGroupListItemType} from '@libs/SearchUIUtils';
77
import type {BaseListItemProps, ExtendedTargetedEvent, ListItem, SelectionListProps} from './types';
88

99
type BaseSelectionListItemRendererProps<TItem extends ListItem> = Omit<BaseListItemProps<TItem>, 'onSelectRow'> &
10-
Pick<SelectionListProps<TItem>, 'ListItem' | 'shouldIgnoreFocus' | 'shouldSingleExecuteRowSelect'> & {
10+
Pick<SelectionListProps<TItem>, 'ListItem' | 'shouldIgnoreFocus' | 'shouldSingleExecuteRowSelect' | 'canShowProductTrainingTooltip'> & {
1111
index: number;
1212
selectRow: (item: TItem, indexToFocus?: number) => void;
1313
setFocusedIndex: ReturnType<typeof useArrowKeyFocusManager>[1];
@@ -44,6 +44,7 @@ function BaseSelectionListItemRenderer<TItem extends ListItem>({
4444
singleExecution,
4545
titleContainerStyles,
4646
shouldUseDefaultRightHandSideCheckmark,
47+
canShowProductTrainingTooltip = true,
4748
}: BaseSelectionListItemRendererProps<TItem>) {
4849
const handleOnCheckboxPress = () => {
4950
if (isTransactionGroupListItemType(item)) {
@@ -94,6 +95,7 @@ function BaseSelectionListItemRenderer<TItem extends ListItem>({
9495
titleStyles={titleStyles}
9596
titleContainerStyles={titleContainerStyles}
9697
shouldUseDefaultRightHandSideCheckmark={shouldUseDefaultRightHandSideCheckmark}
98+
canShowProductTrainingTooltip={canShowProductTrainingTooltip}
9799
/>
98100
{item.footerContent && item.footerContent}
99101
</>

src/components/SelectionList/InviteMemberListItem.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,15 +42,21 @@ function InviteMemberListItem<TItem extends ListItem>({
4242
onFocus,
4343
shouldSyncFocus,
4444
wrapperStyle,
45+
canShowProductTrainingTooltip = true,
4546
}: InviteMemberListItemProps<TItem>) {
4647
const styles = useThemeStyles();
4748
const theme = useTheme();
4849
const StyleUtils = useStyleUtils();
4950
const {translate} = useLocalize();
5051
const {isBetaEnabled} = usePermissions();
52+
5153
const {renderProductTrainingTooltip, shouldShowProductTrainingTooltip} = useProductTrainingContext(
5254
CONST.PRODUCT_TRAINING_TOOLTIP_NAMES.SCAN_TEST_TOOLTIP_MANAGER,
53-
!getIsUserSubmittedExpenseOrScannedReceipt() && isBetaEnabled(CONST.BETAS.NEWDOT_MANAGER_MCTEST) && isSelectedManagerMcTest(item.login) && !item.isSelected,
55+
canShowProductTrainingTooltip &&
56+
!getIsUserSubmittedExpenseOrScannedReceipt() &&
57+
isBetaEnabled(CONST.BETAS.NEWDOT_MANAGER_MCTEST) &&
58+
isSelectedManagerMcTest(item.login) &&
59+
!item.isSelected,
5460
);
5561

5662
const focusedBackgroundColor = styles.sidebarLinkActive.backgroundColor;

src/components/SelectionList/types.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,9 @@ type ListItem<K extends string | number = string> = {
212212

213213
/** Boolean whether to display the right icon */
214214
shouldShowRightIcon?: boolean;
215+
216+
/** Whether product training tooltips can be displayed */
217+
canShowProductTrainingTooltip?: boolean;
215218
};
216219

217220
type TransactionListItemType = ListItem &
@@ -433,7 +436,10 @@ type SplitListItemProps<TItem extends ListItem> = ListItemProps<TItem>;
433436

434437
type TransactionSelectionListItem<TItem extends ListItem> = ListItemProps<TItem> & Transaction;
435438

436-
type InviteMemberListItemProps<TItem extends ListItem> = UserListItemProps<TItem>;
439+
type InviteMemberListItemProps<TItem extends ListItem> = UserListItemProps<TItem> & {
440+
/** Whether product training tooltips can be displayed */
441+
canShowProductTrainingTooltip?: boolean;
442+
};
437443

438444
type UserSelectionListItemProps<TItem extends ListItem> = UserListItemProps<TItem>;
439445

@@ -810,6 +816,9 @@ type SelectionListProps<TItem extends ListItem> = Partial<ChildrenProps> & {
810816

811817
/** Whether to show the default right hand side checkmark */
812818
shouldUseDefaultRightHandSideCheckmark?: boolean;
819+
820+
/** Whether product training tooltips can be displayed */
821+
canShowProductTrainingTooltip?: boolean;
813822
} & TRightHandSideComponent<TItem>;
814823

815824
type SelectionListHandle = {

src/pages/iou/request/MoneyRequestParticipantsSelector.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ function MoneyRequestParticipantsSelector({
120120
const isCategorizeOrShareAction = [CONST.IOU.ACTION.CATEGORIZE, CONST.IOU.ACTION.SHARE].some((option) => option === action);
121121
const [tryNewDot] = useOnyx(ONYXKEYS.NVP_TRY_NEW_DOT, {canBeMissing: true});
122122
const hasBeenAddedToNudgeMigration = !!tryNewDot?.nudgeMigration?.timestamp;
123+
const canShowManagerMcTest = useMemo(() => !hasBeenAddedToNudgeMigration && action !== CONST.IOU.ACTION.SUBMIT, [hasBeenAddedToNudgeMigration, action]);
123124

124125
const importAndSaveContacts = useCallback(() => {
125126
contactImport().then(({contactList, permissionStatus}: ContactImportResult) => {
@@ -181,7 +182,7 @@ function MoneyRequestParticipantsSelector({
181182
shouldSeparateSelfDMChat: iouType !== CONST.IOU.TYPE.INVOICE,
182183
shouldSeparateWorkspaceChat: true,
183184
includeSelfDM: !isMovingTransactionFromTrackExpense(action) && iouType !== CONST.IOU.TYPE.INVOICE,
184-
canShowManagerMcTest: !hasBeenAddedToNudgeMigration && action !== CONST.IOU.ACTION.SUBMIT,
185+
canShowManagerMcTest,
185186
isPerDiemRequest,
186187
},
187188
);
@@ -204,7 +205,7 @@ function MoneyRequestParticipantsSelector({
204205
options.reports,
205206
participants,
206207
isPerDiemRequest,
207-
hasBeenAddedToNudgeMigration,
208+
canShowManagerMcTest,
208209
]);
209210

210211
const chatOptions = useMemo(() => {
@@ -592,6 +593,7 @@ function MoneyRequestParticipantsSelector({
592593
shouldPreventDefaultFocusOnSelectRow={!canUseTouchScreen()}
593594
onSelectRow={onSelectRow}
594595
shouldSingleExecuteRowSelect
596+
canShowProductTrainingTooltip={canShowManagerMcTest}
595597
headerContent={
596598
<ImportContactButton
597599
showImportContacts={showImportContacts}

0 commit comments

Comments
 (0)