Skip to content

fix: observe existing simulator root for size updates#27

Merged
lihbr merged 1 commit into
prismicio:masterfrom
ruben-prismic:rg/observe-existing-simulator-root
May 25, 2026
Merged

fix: observe existing simulator root for size updates#27
lihbr merged 1 commit into
prismicio:masterfrom
ruben-prismic:rg/observe-existing-simulator-root

Conversation

@ruben-prismic

@ruben-prismic ruben-prismic commented May 25, 2026

Copy link
Copy Markdown
Contributor

Description

Fixes slice zone size updates when .slice-simulator--root already exists before SimulatorManager initializes its listeners.

The existing MutationObserver only handles roots added later. This calls the existing observer setup once during listener initialization and adds a regression test for that behavior.

Checklist

  • If my changes require tests, I added them.
  • If my changes affect backward compatibility, it has been discussed.
  • If my changes require an update to the CONTRIBUTING.md guide, I updated it.

How to QA

  • Run npm run test.

View with Codesmith Autofix with Codesmith
Need help on this PR? Tag @codesmith with what you need. Autofix is disabled.


Note

Low Risk
Small listener-init fix plus a unit test; no auth, data, or API contract changes.

Overview
Fixes slice zone size reporting when .slice-simulator--root is already in the DOM before listeners start. A MutationObserver only ran observeSimulatorRoot when children were added later, so an existing root never got a ResizeObserver until the DOM changed again.

SimulatorManager now calls observeSimulatorRoot() once right after wiring the mutation observer, reusing the same hook that attaches the resize observer. A regression test stubs ResizeObserver and asserts the existing root is observed when sliceZoneSizeAPI is enabled.

Reviewed by Cursor Bugbot for commit 727b2a1. Bugbot is set up for automated code reviews on this repo. Configure here.

Co-authored-by: Cursor <cursoragent@cursor.com>
@lihbr lihbr merged commit 070615f into prismicio:master May 25, 2026
2 of 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.

3 participants