fix(edit-content): clear stale field state on manual locale translation#35596
Merged
adrianjm-dotCMS merged 9 commits intoMay 11, 2026
Merged
Conversation
…oup changes - Refactored `getInstance` method to reset and create a new instance of `AngularFormBridge` when called with a different `FormGroup` or `NgZone`. - Removed console warning for instance retrieval with different parameters, ensuring a new instance is returned instead. - Updated unit tests to reflect the new behavior, ensuring instances are correctly managed based on form changes. This change enhances the reliability of instance management in dynamic form scenarios.
9 tasks
This comment was marked as resolved.
This comment was marked as resolved.
…t form - Added `isManualTranslation` parameter to resolution functions to handle manual translation scenarios. - Updated resolution functions to return `null` for manual translations when contentlet is not available. - Introduced `$shouldRenderFields` signal to manage field rendering based on manual translation state. - Modified HTML template to conditionally render fields based on the new signal. This change improves the handling of manual translations, ensuring that the form behaves correctly when translating content.
…m rendering - Removed unnecessary `isManualTranslation` parameter from `hostFolderResolutionFn`, simplifying the resolution logic. - Updated `DotEditContentFormComponent` to utilize `untracked` for managing reactivity during locale copying, ensuring that only relevant state changes trigger re-execution. - Introduced `#flushFieldsForRerender` method to reset field components, enhancing the form's responsiveness to manual translation scenarios. - Adjusted `locales.feature.ts` to correctly set `isManualTranslation` based on the copy type. These changes enhance the edit content form's behavior during manual translations, ensuring a smoother user experience.
…nctions Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
oidacra
reviewed
May 7, 2026
oidacra
reviewed
May 7, 2026
oidacra
reviewed
May 7, 2026
oidacra
reviewed
May 7, 2026
oidacra
reviewed
May 7, 2026
…ge behavior - Reset isManualTranslation to false when switching to a translated locale - Guard AngularFormBridge.destroy() against orphan instances decrementing live refCount - Make $shouldRenderFields protected readonly in dot-edit-content-form component - Add isManualTranslation assertions and reset test to locales.feature.spec - Add fakeAsync tests for $shouldRenderFields toggle on manual translation - Document categoryResolutionFn array-branch asymmetry with isManualTranslation Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…1-stale-field-state-content-editor Co-authored-by: Cursor <cursoragent@cursor.com> # Conflicts: # core-web/libs/edit-content/src/lib/components/dot-edit-content-form/dot-edit-content-form.component.ts
zJaaal
approved these changes
May 11, 2026
- Replace nested ternaries with early returns in defaultResolutionFn, textFieldResolutionFn, and blockEditorResolutionFn - Flatten isCopyingLocale effect with early return - Refactor getInitialFieldValue to use an object parameter - Fix accumulating onDestroy callbacks in #flushFieldsForRerender Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
dario-daza
approved these changes
May 11, 2026
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.
Summary
Fixes the two scenarios from issue #35521 where stale form field state was not properly cleared:
fix(angular-form-bridge)): When switching between content items of the same type, stale values from the previous item were shown. Fixed by resetting theAngularFormBridgeinstance when called with a differentFormGroup.fix(edit-content)): When changing locale via Translate Manually, not all fields were cleared — fields with internal state (binary/image, date picker, relationship, custom fields) retained values from the original locale.Screen.Recording.2026-05-06.at.3.55.27.PM.mov
Root Cause (Scenario 2)
Two layers of state weren't being cleared on manual translation:
field.defaultValuewhencontentletwasnull, so fields with a configured default showed that default instead of empty.FormGroupwithnullvalues wasn't enough to clear what these components rendered.Changes
edit-content.store.ts— AddsisManualTranslation: booleanto the store state.locales.feature.ts— SetsisManualTranslation: trueinpatchStatewhen the user selects "Translate Manually".dot-edit-content-form-resolutions.ts— AddsisManualTranslationas an optional 4th parameter toFnResolutionValueand updates all resolution functions that fell back tofield.defaultValuewhencontentletwasnull. WhenisManualTranslationistrue, they returnnull/[]instead, ensuring FormControls start truly empty.dot-edit-content-form.component.ts/.html— Adds$shouldRenderFieldssignal. WhenisManualTranslationistrue, the copy-locale effect sets the signal tofalse(destroying all field components) then restores it totrueviasetTimeout(recreating them fresh). Components recreated withcontentlet = nullinitialize to their empty/default visual state without any prior data.Checklist
Additional Info
The
$shouldRenderFieldstoggle causes a one-frame flash while field components are destroyed and recreated. This is intentional and expected — it happens only on the "Translate Manually" path after the user confirms the dialog.This PR fixes: #35521
This PR fixes: #35521