Skip to content

fix(image): editor canvas ignores node inline styles on images#253

Merged
DavidBabinec merged 1 commit into
CoreBunch:mainfrom
borskyj:fix/image-editor-inline-styles
Jul 24, 2026
Merged

fix(image): editor canvas ignores node inline styles on images#253
DavidBabinec merged 1 commit into
CoreBunch:mainfrom
borskyj:fix/image-editor-inline-styles

Conversation

@borskyj

@borskyj borskyj commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

Fixes #252

Problem

In the design canvas, base.image nodes ignore their inlineStyles once the media asset resolves — e.g. a header logo with height: 1.75rem; width: auto renders at intrinsic size and fills the frame. The published page is correct; this is an editor-only WYSIWYG break.

Cause

In ImageEditor.tsx (resolved-asset branch) the explicit style={style} prop comes after the {...nodeWrapperProps} spread, so it always overrides nodeWrapperProps.style — the channel that carries node.inlineStyles into the canvas. This happens both when style is the BlurHash backdrop object and when it is undefined (an explicit style={undefined} still wins over a spread value in React). The raw-src fallback branch has no explicit style prop, which is why inline styles briefly apply until the asset cache resolves, then vanish.

Fix

Merge instead of clobber: spread nodeWrapperProps?.style into the backdrop object (backdrop keys win — they only touch background-*), and pass nodeWrapperProps?.style through when there is no backdrop.

Verification

  • tsc --noEmit clean, eslint clean on the changed file.
  • Reproduced on a live site: logo node with inlineStyles height: 1.75rem; width: auto; display: block rendered at ~2000px wide in the canvas before the change; published output was already correct.

🤖 Generated with Claude Code

In ImageEditor's resolved-asset branch the explicit style prop came after
the {...nodeWrapperProps} spread, so it always overrode
nodeWrapperProps.style - the channel that carries node.inlineStyles into
the canvas. Even style={undefined} wins over a spread value, so any image
with a resolved library asset rendered at intrinsic size in the editor
while the published page honoured the inline styles.

Merge the BlurHash backdrop with nodeWrapperProps.style instead (backdrop
keys win, they only touch background-*), and fall back to
nodeWrapperProps.style when there is no backdrop. The raw-src fallback
branch was already correct, which is why inline styles briefly applied
until the asset cache resolved.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@DavidBabinec
DavidBabinec merged commit 5c7e1a2 into CoreBunch:main Jul 24, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: ditor canvas ignores node inline styles on images — explicit styleprop clobbersnodeWrapperProps.style` in ImageEditor

3 participants