Add replace: true for logic back button behavior where it makes sense

Closes #3100
This commit is contained in:
Kalle
2026-05-24 11:17:53 +03:00
parent d9e893fa0f
commit 508f910c68
5 changed files with 37 additions and 20 deletions

View File

@@ -56,6 +56,7 @@ export function MatchTabs({ children, tabs }: MatchTabsProps) {
{
preventScrollReset: true,
defaultShouldRevalidate: false,
replace: true,
},
)
}

View File

@@ -112,10 +112,16 @@ export default function ArtPage() {
key={filteredTag}
tags={data.allTags}
onSelectionChange={(tagName) => {
setSearchParams((prev) => {
prev.set(FILTERED_TAG_KEY_SEARCH_PARAM_KEY, tagName as string);
return prev;
});
setSearchParams(
(prev) => {
prev.set(
FILTERED_TAG_KEY_SEARCH_PARAM_KEY,
tagName as string,
);
return prev;
},
{ replace: true },
);
}}
/>
</div>
@@ -128,10 +134,13 @@ export default function ArtPage() {
variant="minimal-destructive"
icon={<X />}
onPress={() => {
setSearchParams((prev) => {
prev.delete(FILTERED_TAG_KEY_SEARCH_PARAM_KEY);
return prev;
});
setSearchParams(
(prev) => {
prev.delete(FILTERED_TAG_KEY_SEARCH_PARAM_KEY);
return prev;
},
{ replace: true },
);
}}
data-testid="clear-filter-button"
>
@@ -142,13 +151,16 @@ export default function ArtPage() {
<SendouTabs
selectedKey={selectedTab}
onSelectionChange={(key) => {
setSearchParams((prev) => {
prev.set(TAB_KEY, key as string);
if (key === TABS.RECENTLY_UPLOADED) {
prev.delete(FILTERED_TAG_KEY_SEARCH_PARAM_KEY);
}
return prev;
});
setSearchParams(
(prev) => {
prev.set(TAB_KEY, key as string);
if (key === TABS.RECENTLY_UPLOADED) {
prev.delete(FILTERED_TAG_KEY_SEARCH_PARAM_KEY);
}
return prev;
},
{ replace: true },
);
}}
>
<SendouTabList>

View File

@@ -108,10 +108,13 @@ export default function LeaderboardsPage() {
value={selectValue()}
onChange={(e) => {
const [type, season] = e.target.value.split(";");
setSearchParams({
[TYPE_SEARCH_PARAM_KEY]: type,
[SEASON_SEARCH_PARAM_KEY]: season,
});
setSearchParams(
{
[TYPE_SEARCH_PARAM_KEY]: type,
[SEASON_SEARCH_PARAM_KEY]: season,
},
{ replace: true },
);
}}
>
{Seasons.allStarted().map((season) => {

View File

@@ -59,7 +59,7 @@ export default function PlusSuggestionsPage() {
const tierVisible = searchParamsToLegalTier(searchParams);
const handleTierChange = (tier: string) => {
setSearchParams({ tier });
setSearchParams({ tier }, { replace: true });
};
const visibleSuggestions = data.suggestions.filter(

View File

@@ -68,6 +68,7 @@ export default function SettingsPage() {
}
setSearchParams(next, {
defaultShouldRevalidate: false,
replace: true,
});
};