Issue #3591857: Removing a media item from one image prop deletes every other media-backed prop's value
Fixes #3591857 (closed).
When a media item is removed from one prop, buildRemoveModel() synced every prop's source.value from the Redux model's resolved values. After any prior layout PATCH round-trip, resolved for media-backed props holds server-evaluated objects ({src, alt, width, height}), not media IDs. The server (clientModelToInput()) cannot store those values, treats the untouched props as empty, and silently drops their stored input.
This MR limits the rewrite to the removed prop only. The removed prop keeps its existing behavior: [] for optional props (explicit deletion), the default resolved value for required props. All other props' sources are sent unchanged.
Reproduced and verified manually on both an SDC (sdc.canvas_test_sdc.mixed-images-with-example) and a code component with two image props.
Test coverage
A Playwright regression test is included in optionalImageDefault.spec.ts: it populates two image props on mixed-images-with-example, removes one, and asserts the other survives in the preview, the widget, and after an editor reload. Verified red against the unfixed code (4/4 runs) and green with the fix (3/3 runs). addMediaImage gained an optional fieldset scope so it can target one media widget among several.
Testing instructions
- Create a component with two image props (e.g. enable
canvas_test_sdcand use "Canvas test SDC with mixed optional and required images"). - Add the component to a page in the Canvas editor.
- Add a different media image to each of the two props.
- Click the X (remove) button on one prop's media item.
- Without this MR: the other prop's image disappears from the preview and its input is missing from the PATCH response model. With this MR: only the removed prop is cleared; the other prop keeps its image, also after reload and publish.
AI disclosure
AI-Generated: Yes (Used Claude Code to diagnose the root cause, write the fix, and draft this MR; the fix was manually verified by a human on a local site).