-
Notifications
You must be signed in to change notification settings - Fork 2.7k
fix(ui): ensure current locale always reflected in URL #13087
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
base: main
Are you sure you want to change the base?
Conversation
📦 esbuild Bundle Analysis for payloadThis analysis was generated by esbuild-bundle-analyzer. 🤖
Largest pathsThese visualization shows top 20 largest paths in the bundle.Meta file: packages/next/meta_index.json, Out file: esbuild/index.js
Meta file: packages/payload/meta_index.json, Out file: esbuild/index.js
Meta file: packages/payload/meta_shared.json, Out file: esbuild/exports/shared.js
Meta file: packages/richtext-lexical/meta_client.json, Out file: esbuild/exports/client_optimized/index.js
Meta file: packages/ui/meta_client.json, Out file: esbuild/exports/client_optimized/index.js
Meta file: packages/ui/meta_shared.json, Out file: esbuild/exports/shared_optimized/index.js
DetailsNext to the size is how much the size has increased or decreased compared with the base branch of this PR.
|
@jacobsfletch if you would like to review this or talk about it lmk! I worked with Jess on this approach. Originally it was a useEffect that re-rendered the page with the locale when it was missing but that added 2 entries into the history stack. I recommended that we go with this approach, where we purposefully set the locale on routes and redirect on the server (to prevent history stack increasing). But would like to know if you have any thoughts. |
What?
This PR ensures that the current locale is always reflected in the URL (
?locale=xx
) across the admin UI.This change is applied in
initPage
in thenext
package to automatically append the URL.To prevent full page reloads when navigating to URLs that are missing the
locale
parameter, the following internal links have been updated to include the locale:Why?
Previously, if a user navigated to a localized route and then used the browser's back button to return to a URL with no locale specified (i.e. no
?locale=
in the URL), the following issues occur:This creates a risk of accidental data loss and a confusing UX experience.
How?
initPage
, we add the?locale=xx
param if missing and redirect to the same URL with the param added.?locale=xx
to avoid unnecessary hard refreshes.This allows us to explicitly reset the locale when the user is navigating back/forward using browser buttons.
Testing
Test using
localization
andposts
. E2E test added totests/localization
.Reported by client.