Repository navigation
fix(studio): replacing an image's fill on an img changes its picture - #5170
Merged
Merged
Conversation
miguel-heygen
marked this pull request as ready for review
October 7, 2026 07:51
Edit accuracy: accurate 2059 (base branch 2059), smooth 1609 of thoseThe gate passes. Quarantined, measured but not gated (0) |
jrusso1020
approved these changes
Oct 7, 2026
jrusso1020
left a comment
Collaborator
There was a problem hiding this comment.
Approving. Replacing an <img> through Fill now changes its picture instead of writing a background behind it.
What I checked
propertyPanelFill.tsx: for animg, every write (upload, project asset, external URL) goes throughcommitImage, which writessrcwith the existing attribute writer. Other elements still getbackground-image, unchanged. Both inspectors pass the writer through, and both now show Image mode for animg.- The write path is the same one the loop and link controls already use (
handleDomHtmlAttributeCommit→html-attributeop).srcis on the allow list inhtmlAttrSafety.ts, and the commit reloads the preview after it saves. - In a nested composition,
srcis written relative to the source file (../assets/new.png). That matches how a timeline asset drop writessrc(resolveTimelineAssetSrc), and the runtime rewrites sub-composition paths against the file's URL. So the saved file and the render agree. - The
decodeURIComponentguard fixes a real crash: a literal%in a source (100%.png, an inline SVG withwidth="100%") used to throw while rendering the panel. - Locally,
propertyPanelImageFill.test.tsxandpropertyPanelFlatStyleSections.test.tsxpass, 53/53.
Nits (optional)
- If an
imghas asrcset, the browser keeps showing thesrcsetchoice aftersrcchanges, so the picture still won't change. That's rare in compositions. A one-line fix is to clearsrcset(andsizes) when replacing. - In a nested composition, the preview gets the raw relative path before it reloads, so it resolves against the main document and shows a broken image for a moment. The reload fixes it. I'm only mentioning it in case anyone sees the flash.
- An
imgthat already has a straybackground-imagefrom the old behaviour can't have it cleared from Fill any more, because clearing now leavessrcalone. It's hidden behind the picture, so it's harmless.
Verdict: APPROVE
Reasoning: The fix uses the existing attribute writer and the existing source-relative path rule, the img and non-img paths are both tested in both inspectors, and nothing here blocks.
— Rames
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.
Replacing an image through Fill → Image previously wrote a CSS background behind the existing opaque picture. The shared image field now uses the existing HTML attribute writer to replace an img's src, shows its current source, and preserves that source when cleared. Other elements retain background-image replacement and clearing. Both classic and flat inspectors use the fix; assets selected in nested compositions keep source-relative paths.
Fixes #5167.
Validation: the new control regressions fail on main because replacement leaves src unchanged. The focused 16-test suite passes three consecutive runs, the existing flat style suite passes 37 tests, and Studio typecheck passes. Real Studio fixture proof reproduces the old red image after replacement on main and shows the replacement blue image after the fix, including reload, a fresh document loaded from persisted HTML, and the producer-rendered frame. Raw-percent filenames and inline SVG sources are covered by regressions that fail before the path-decoding fix.
Before
Studio on main after replacement still shows the old red image.
After
The settled Studio preview and timeline both show the blue replacement, and Fill shows its current source. The producer frame renders the same replacement from saved HTML.