Conversation
|
Claude finished @oidacra's task in 2m 23s —— View job Code Review
The fix is well-reasoned. Two genuine issues and a few smaller notes follow.
|
Two races in the new edit-content mode could blank category fields when a contentlet has more than one category field: - The lock/unlock action replaced the whole contentlet in the store with the server response, which triggered a full form rebuild. During the rebuild, async category hierarchy fetches would reset form controls. Patch only the lock-related properties so unrelated field state is kept. - The category field's sync effect emitted the store's initial empty selected into the form control before the async hierarchy fetch completed. If the user saved during that window, the field was sent empty. Wait for ComponentStatus.LOADED before propagating values. Also guard the form-rebuild effect so it only reinitializes when the contentlet identity (identifier|inode|modDate) actually changes, not on every state-only update. Closes #33931
- Guard lock/unlock handlers against a null contentlet (edge case when the user navigates away while the request is in-flight). - Keep the form revision key in sync when isCopyingLocale rebuilds the form, so the main reinit effect doesn't rebuild a second time. - Document why the category field's LOADED guard also skips the ERROR state (better stale than blank). - Use a complete DotCMSContentlet (with lock fields) in the lock/unlock mocks so post-lock assertions would be meaningful. - Add a regression test asserting the form is not reinitialized when only the lock state changes.
1934cd0 to
137b634
Compare
…d-when-using-new-edit-contentlet-mode
Summary
Fixes two races in the new edit-content mode that could silently blank category fields when a contentlet has more than one Category field.
Closes #33931
Root causes
Lock/unlock replaced the whole contentlet.
withLock()patched the store with the full server response, which changed the contentlet reference and forcedDotEditContentFormComponentto rebuild the form. During the rebuild, the async category hierarchy fetch would briefly holdselected = []and the effect would write that empty value into the form control. Saving during that window blanked the field.Category sync effect fired before the hierarchy fetch completed. In
dot-category-field.component.ts, the effect that mirrorsstore.selected()→ form control ran immediately on mount with the initial empty state, overwriting the form control's resolved inodes. Intermittent because the race depends on how quickly the user interacts after mount (or after a form rebuild).Changes
store/features/lock/lock.feature.ts— on lock/unlock, patch onlylocked,lockedBy,lockedByName,lockedOn, preserving the rest of the contentlet.components/dot-edit-content-form/dot-edit-content-form.component.ts— track a revision key (identifier|inode|modDate) and only rebuild the form when the contentlet's identity actually changes, not on every state-only update.fields/dot-edit-content-category-field/components/dot-category-field/dot-category-field.component.ts— the sync effect now waits untilComponentStatus.LOADEDbefore emitting to the form control, so the initial emptyselectedno longer wipes the value.Test plan
edit-contentunit tests pass (yarn nx test edit-content).This PR fixes: #33931