fix(legacy-edit-content): preserve relationship context across language switches#36001
Open
adrianjm-dotCMS wants to merge 2 commits into
Open
fix(legacy-edit-content): preserve relationship context across language switches#36001adrianjm-dotCMS wants to merge 2 commits into
adrianjm-dotCMS wants to merge 2 commits into
Conversation
…ge switches When creating a child contentlet via "Relate New" from a relationship field, switching language before saving caused the relationship params (relwith, reltype, etc.) to be dropped from the URL, so the auto-link to the parent was never created. Fix includes the localStorage cleanup for the "Return to" breadcrumb button which had the same language-switch regression. Fixes #35472 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Contributor
|
Claude finished @adrianjm-dotCMS's task in 51s —— View job Rollback Safety Analysis
Result: ✅ Safe To RollbackThe changes in this PR are limited to a single JSP file ( Category-by-category check:
Summary of changes:
Rolling back to N-1 simply reverts these UI behaviors; no database state, ES index, or API contract is affected. Label applied: AI: Safe To Rollback |
Updated the logic in `edit_contentlet_basic_properties.jsp` to ensure that relationship parameters (`relisparent`, `reltype`, `relname`, `relname_inodes`) are only added to the URL if they are present in the request. This prevents potential issues with missing parameters when creating child contentlets, enhancing the reliability of the relationship linking process.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Two related regressions in the legacy edit content screen when using relationship fields:
"Return to [parent]" button disappears after switching language — the button was visible when first opening the child contentlet, but switching language reloaded the page and the button was gone.
Relationship not created when switching language before saving — when creating a new child contentlet via "Relate New" and switching language before saving, the relationship with the parent was never established. The content was created but appeared unlinked.
Both issues only affected non-default languages. English (default) worked correctly.
Screen.Recording.2026-06-05.at.12.05.12.PM.mov
Root Cause
Both bugs share the same root: data stored for the language-switch navigation URL was incomplete.
Bug 1 — localStorage cleared too early:
showRelationshipReturn()calledlocalStorage.removeItem()immediately after rendering the "Return to" button. On language switch the page reloaded, found localStorage empty, and skipped the button.Bug 2 — Relationship params missing from
editURL:The language selector builds its URL from
editURL, which was constructed without the relationship params (relwith,relisparent,reltype,relname,relname_inodes). Switching language navigated to a URL without those params, so on saveEditContentletActionhad no context to auto-link the new content to its parent.Changes
edit_contentlet_basic_properties.jsplocalStorage.removeItem()into the button click handler so the "Return to" breadcrumb survives language-switch reloads; cleared only when the user actually navigates back to the parent.relwith != null), include all relationship params ineditURLso they are preserved whenchangeLanguage()navigates to a different language version.Test Plan
Fixes #35472