Skip to content

Commit e7c557a

Browse files
committed
Fix: Persist query parameters on locale change
1 parent 3847156 commit e7c557a

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/app/services/translate/translate.service.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,16 @@ export class TranslateService {
4848

4949
private async addLocaleToSearchParams() {
5050
const locale = await firstValueFrom(this.selectedLanguage$);
51-
const currentParams = this.router.getCurrentNavigation()?.extras?.queryParams;
51+
const windowQueryParams = new URLSearchParams(window.location.search);
52+
const queryParams = {
53+
...Object.fromEntries(windowQueryParams.entries()),
54+
...this.router.getCurrentNavigation()?.extras.state,
55+
locale: locale,
56+
};
5257

5358
this.router.navigate([], {
5459
relativeTo: this.activatedRoute,
55-
queryParams: { ...currentParams, locale },
60+
queryParams: queryParams,
5661
queryParamsHandling: 'merge',
5762
});
5863
}

0 commit comments

Comments
 (0)