Skip to content

[Part 1 of 2] Plugin SDK fixes: dark-mode input surface, ctx.rootFontSize, message-origin fast path - #56

Open
roger-datocms wants to merge 3 commits into
masterfrom
fix/plugin-sdk-issues-54-55-fontsize
Open

roger-datocms wants to merge 3 commits into
masterfrom
fix/plugin-sdk-issues-54-55-fontsize

Conversation

@roger-datocms

@roger-datocms roger-datocms commented Sep 14, 2026

Copy link
Copy Markdown
Member

DO NOT MERGE — draft for review only.

Merge order — 1 of 2 (merge this first).
The other one, https://github.com/datocms/cms/pull/394, must come AFTER this one.

Fixes two GitHub issues and one community thread about DatoCMS plugins. SDK side.

1. Dark-mode input surface (issue #54)

react-ui TextInput, TextareaInput and SelectInput now paint on
--color--surface-raised, the token native inputs use. Previously they sat on the
page-background token, so in dark mode they were one shade darker than the
controls around them.

Dark-mode input colour, before and after

The same token miss affected the search box inside Dropdown menus
(.Dropdown__menu__search__input), which sat one shade darker than its own
raised menu panel. Now fixed too:

Dropdown search box, before and after

2. ctx.rootFontSize (community thread 8663)

New base property carrying the host's <html> font size in px. The runtime
mirrors it onto the plugin's <html>, so rem-based tokens measure the same
inside the frame as in the host. (Host sends it from the cms PR.) The runtime
also guards against a non-positive value collapsing the plugin to 0px.

Font size, before and after

3. Message-origin fast path (issue #55)

A capture-phase message listener reads event.origin before Penpal reads
event.data. Chrome slows the deserialization of cross-origin messages ≥16 KB
when data is read first (MaskDeserializationTimings); reading origin first
avoids it. Penpal is unchanged. Live micro-benchmark in Chrome, same 266 KB
message to two cross-origin iframes:

Synthetic test:

Deserialize cost, data-first vs origin-first

More realistic plugin test, before/after

(mean, P95, and max/worst should all improve)

typing-lag-before.mp4
typing-lag-after.mp4

Notes

Tested live against a local dev project. Images are hosted as DatoCMS assets
(no binaries committed to this repo).

🤖 Generated with Claude Code

https://claude.ai/code/session_01RtS2SCFb7RgPeThjnPVngz

@pkg-pr-new

pkg-pr-new Bot commented Sep 14, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/datocms-react-ui@20f0db0
npm i https://pkg.pr.new/datocms-plugin-sdk@20f0db0

commit: 20f0db0

@roger-datocms
roger-datocms force-pushed the fix/plugin-sdk-issues-54-55-fontsize branch from 79f6adb to 75810a1 Compare September 14, 2026 23:14
…gin fast path

- react-ui TextInput/TextareaInput/SelectInput paint on the raised surface
  token, matching native inputs (dark-mode issue #54).
- New ctx.rootFontSize; the runtime mirrors the host root font size onto the
  plugin so rem-based tokens match the host (community thread 8663).
- Read event.origin before Penpal reads event.data so Chrome skips its slow
  cross-origin deserialization path (issue #55).
- Changesets included.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RtS2SCFb7RgPeThjnPVngz
@roger-datocms
roger-datocms force-pushed the fix/plugin-sdk-issues-54-55-fontsize branch from 75810a1 to b3e97d8 Compare September 14, 2026 23:45
applyHostAppearance runs on every ctx update (every keystroke in a sibling
field). Writing documentElement.style.fontSize unconditionally reflowed the
whole rem-based plugin frame each time; only write when the value actually
changed, matching applyColorScheme.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RtS2SCFb7RgPeThjnPVngz
@roger-datocms roger-datocms changed the title [Do not merge] Plugin SDK fixes: dark-mode input surface, ctx.rootFontSize, message-origin fast path [Part 1 of 2] Plugin SDK fixes: dark-mode input surface, ctx.rootFontSize, message-origin fast path Sep 15, 2026
@roger-datocms roger-datocms self-assigned this Sep 15, 2026
@roger-datocms roger-datocms added the enhancement New feature or request label Sep 15, 2026
@roger-datocms
roger-datocms marked this pull request as ready for review September 15, 2026 23:45
`!(next > 0)` let Infinity through; use Number.isFinite so the guard matches
its stated intent (reject non-positive and non-finite values).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RtS2SCFb7RgPeThjnPVngz
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant