Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CP Staging] Fix saved search names #49235

Merged
merged 4 commits into from
Sep 16, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
110 changes: 56 additions & 54 deletions src/pages/Search/SearchTypeMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -96,63 +96,65 @@ function SearchTypeMenu({queryJSON}: SearchTypeMenuProps) {
[showDeleteModal],
);

const createSavedSearchMenuItem = useCallback(
(item: SaveSearchItem, key: string, isNarrow: boolean) => {
const baseMenuItem: SavedSearchMenuItem = {
key,
title: item.name,
hash: key,
query: item.query,
shouldShowRightComponent: true,
focused: Number(key) === hash,
onPress: () => {
SearchActions.clearAllFilters();
Navigation.navigate(ROUTES.SEARCH_CENTRAL_PANE.getRoute({query: item?.query ?? ''}));
const createSavedSearchMenuItem = (item: SaveSearchItem, key: string, isNarrow: boolean) => {
let title = item.name;
if (title === item.query) {
const jsonQuery = SearchUtils.buildSearchQueryJSON(item.query) ?? ({} as SearchQueryJSON);
title = SearchUtils.getSearchHeaderTitle(jsonQuery, personalDetails, cardList, reports, taxRates);
}
const baseMenuItem: SavedSearchMenuItem = {
key,
title,
hash: key,
query: item.query,
shouldShowRightComponent: true,
focused: Number(key) === hash,
onPress: () => {
SearchActions.clearAllFilters();
Navigation.navigate(ROUTES.SEARCH_CENTRAL_PANE.getRoute({query: item?.query ?? ''}));
},
rightComponent: (
<ThreeDotsMenu
menuItems={getOverflowMenu(item.name, Number(key), item.query)}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI, This PR missed to use title instead of item.name here and caused this bug: #49739, More info in this proposal: #49739 (comment)

anchorPosition={{horizontal: 0, vertical: 380}}
anchorAlignment={{
horizontal: CONST.MODAL.ANCHOR_ORIGIN_HORIZONTAL.RIGHT,
vertical: CONST.MODAL.ANCHOR_ORIGIN_VERTICAL.TOP,
}}
/>
),
styles: [styles.alignItemsCenter],
};

if (!isNarrow) {
return {
...baseMenuItem,
shouldRenderTooltip: !shouldHideSavedSearchRenameTooltip,
tooltipAnchorAlignment: {
horizontal: CONST.MODAL.ANCHOR_ORIGIN_HORIZONTAL.RIGHT,
vertical: CONST.MODAL.ANCHOR_ORIGIN_VERTICAL.BOTTOM,
},
tooltipShiftHorizontal: -32,
tooltipShiftVertical: 15,
tooltipWrapperStyle: [styles.bgPaleGreen, styles.mh4, styles.pv2],
renderTooltipContent: () => {
SearchActions.dismissSavedSearchRenameTooltip();
return (
<View style={[styles.flexRow, styles.alignItemsCenter]}>
<Expensicons.Lightbulb
width={16}
height={16}
fill={styles.colorGreenSuccess.color}
/>
<Text style={[styles.ml1, styles.quickActionTooltipSubtitle]}>{translate('search.saveSearchTooltipText')}</Text>
</View>
);
},
rightComponent: (
<ThreeDotsMenu
menuItems={getOverflowMenu(item.name, Number(key), item.query)}
anchorPosition={{horizontal: 0, vertical: 380}}
anchorAlignment={{
horizontal: CONST.MODAL.ANCHOR_ORIGIN_HORIZONTAL.RIGHT,
vertical: CONST.MODAL.ANCHOR_ORIGIN_VERTICAL.TOP,
}}
/>
),
styles: [styles.alignItemsCenter],
};
}

if (!isNarrow) {
return {
...baseMenuItem,
shouldRenderTooltip: !shouldHideSavedSearchRenameTooltip,
tooltipAnchorAlignment: {
horizontal: CONST.MODAL.ANCHOR_ORIGIN_HORIZONTAL.RIGHT,
vertical: CONST.MODAL.ANCHOR_ORIGIN_VERTICAL.BOTTOM,
},
tooltipShiftHorizontal: -32,
tooltipShiftVertical: 15,
tooltipWrapperStyle: [styles.bgPaleGreen, styles.mh4, styles.pv2],
renderTooltipContent: () => {
SearchActions.dismissSavedSearchRenameTooltip();
return (
<View style={[styles.flexRow, styles.alignItemsCenter]}>
<Expensicons.Lightbulb
width={16}
height={16}
fill={styles.colorGreenSuccess.color}
/>
<Text style={[styles.ml1, styles.quickActionTooltipSubtitle]}>{translate('search.saveSearchTooltipText')}</Text>
</View>
);
},
};
}

return baseMenuItem;
},
[hash, styles, getOverflowMenu, translate, shouldHideSavedSearchRenameTooltip],
);
return baseMenuItem;
};

const savedSearchesMenuItems = () => {
if (!savedSearches) {
Expand Down
Loading