Skip to content

Commit 83b97e9

Browse files
MelvinBotbrunovjk
andcommitted
Use type-based fallback for active tab in SearchTypeMenuNarrow
SearchTypeMenuNarrow determined the active tab using only an exact similarSearchHash match. When filters were applied, the hash changed and no tab matched, losing the highlight on mobile. The wide menu already handled this via useSearchTypeMenuSections' type-based fallback. Pass query params to the hook and use activeItemIndex so both platforms share the same fallback logic. Co-authored-by: Bruno Rocha <brunovjk@users.noreply.github.com>
1 parent cfff715 commit 83b97e9

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

src/pages/Search/SearchTypeMenuNarrow.tsx

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,13 @@ function SearchTypeMenuNarrow({queryJSON, onTabPress}: SearchTypeMenuNarrowProps
7474
const {translate} = useLocalize();
7575
const {isOffline} = useNetwork();
7676
const navigation = useNavigation();
77-
const {typeMenuSections} = useSearchTypeMenuSections();
77+
const {typeMenuSections, activeItemIndex} = useSearchTypeMenuSections({
78+
hash: queryJSON?.hash,
79+
similarSearchHash: queryJSON?.similarSearchHash,
80+
sortBy: queryJSON?.sortBy,
81+
sortOrder: queryJSON?.sortOrder,
82+
type: queryJSON?.type,
83+
});
7884
const personalDetails = usePersonalDetails();
7985
const feedKeysWithCards = useFeedKeysWithAssignedCards();
8086
const [restoreFocusType, setRestoreFocusType] = useState<BaseModalProps['restoreFocusType']>();
@@ -163,6 +169,7 @@ function SearchTypeMenuNarrow({queryJSON, onTabPress}: SearchTypeMenuNarrowProps
163169
.filter((item) => item !== null)
164170
: [];
165171

172+
let typeMenuItemIndex = 0;
166173
for (const section of typeMenuSections) {
167174
if (section.translationPath === 'search.savedSearchesMenuItemTitle') {
168175
tabItems.push(...savedSearchesTabItems);
@@ -178,9 +185,10 @@ function SearchTypeMenuNarrow({queryJSON, onTabPress}: SearchTypeMenuNarrowProps
178185
badgeText,
179186
});
180187
queryMap.set(item.key, {query: item.searchQuery});
181-
if (item.similarSearchHash === queryJSON?.similarSearchHash) {
188+
if (activeItemIndex === typeMenuItemIndex) {
182189
activeKey = item.key;
183190
}
191+
typeMenuItemIndex++;
184192
}
185193
}
186194
}

0 commit comments

Comments
 (0)