Content Workspace: Add variant sync when switching app culture (closes #16853)#22566
Content Workspace: Add variant sync when switching app culture (closes #16853)#22566
Conversation
|
Claude finished @engijlr's task in 2m 45s —— View job PR ReviewTarget: Fixes the language-switch UX bug (#16853): when the app language context changes and the user is viewing a single-variant document route matching the previous culture, the URL is synchronously updated via Suggestions
NotesOrdering: Split-view paths are correctly left alone: Media Workspace Editor: The TODO comment on line 10 notes that this element is "fully identical" with the Media Workspace Editor. However, No breaking changes detected. The change modifies internal behavior only — no public API surface, no exported types, no custom element interface changes. Approved with Suggestions for improvementGood to go, but please carefully consider the importance of the suggestions. |
|
I was just looking to tackle the testing part of this @engijlr. Looks a nice addition and editor friendly update. It mostly works fine, but I found a few edge cases.
|
| const currentPath = window.location.pathname; | ||
| const expectedOldPath = `${this.#workspaceRoute}/${previousCulture}`; | ||
| if (currentPath === expectedOldPath && this.#variants?.some((v) => v.unique === appCulture)) { | ||
| history.replaceState(null, '', `${this.#workspaceRoute}/${appCulture}${window.location.search}`); |
There was a problem hiding this comment.
Could this avoid removing the rest of the URL, so if you have navigated to the info workspace view, then it would be nice to keep that part of the URL. in other words keeping the rest of the url. :-)
There was a problem hiding this comment.
Fixed the two edge cases by extracting the URL sync into a #syncUrlToCulture method. The main issue was that the old code did an exact path match, so it broke when there was extra stuff in the URL like /view/info.
Now it splits the variant part from the rest of the path and keeps whatever comes after. Also, instead of comparing the full variant string, it looks up the variant and matches by culture. I tested all the scenarios manually except segments since I don't have a setup for that.
Summary
Adds a check in the
appLanguageCultureobserver indocument-workspace-editor.element.ts. When the culture changes, if the user is on a single-variant view and the document has a variant for the new culture, it updates the URL to the new culture.Test plan
Fixes #16853