Fix template read-only hint/open firing over editable page content#32
Merged
Conversation
…ge content
The 'Part of Main template — double-click to edit' hover hint fired over the
ENTIRE page (including the active page's own editable content), and
double-clicking that content opened the template instead of editing the node —
breaking inline text editing on any page with a wrapping template.
Root cause: the active document's editable content is spliced into the wrapping
template's base.outlet (CanvasComposedTree), so in the DOM it lives INSIDE the
read-only wrapper element, which carries data-instatic-readonly-* markers. Both
consumers walked straight up with closest('[data-instatic-readonly-*]'), so they
found the wrapper ancestor and treated the editable content as read-only — even
though editable nodes carry their own data-node-id and never the readonly
markers.
Fix: a shared closestReadonlyRegion(target) resolves the NEAREST boundary of
EITHER kind ([data-node-id] | [data-instatic-readonly-label]); an editable node
nearer than any readonly marker means the target is editable, so no hint / no
template-open. Wired into both the hover hint (BreakpointFrame) and the
double-click-to-open (IframeFrameSurface), and dedups the cross-realm
isElementLike helper that was copied in both files.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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.
The bug
The "Part of Main template — double-click to edit" hover hint fired over the entire page — including the active page's own editable content (e.g. the
ABOUTheading), not just the template chrome (header/footer). Worse, double-clicking that editable content opened the template instead of editing the node — which silently breaks inline text editing on any page that has a wrapping template.Root cause
The active document's editable content is spliced into the wrapping template's
base.outlet(CanvasComposedTree), so in the DOM it lives inside the read-only wrapper element. That wrapper carriesdata-instatic-readonly-*markers (it's template chrome). Both consumers resolved the region by walking straight up:So they found the wrapper ancestor and treated the editable page content as read-only — even though editable nodes carry their own
data-node-idand never the read-only markers (the two are mutually exclusive). The "another wrapper" intuition was exactly right.The fix
A shared
closestReadonlyRegion(target)resolves the nearest boundary of either kind —[data-node-id](editable) or[data-instatic-readonly-label](read-only). An editable node nearer than any read-only marker means the target is the active page's own content, so: no hint, no template-open. Wired into both the hover hint and the double-click-to-open, and dedups the cross-realmisElementLikehelper that was copied in both files.Tests
New
closestReadonlyRegionunit tests cover the exact bug (editable node spliced inside a read-only wrapper → no region), plus read-only chrome, unmarked chrome children, plain editable nodes, and non-element targets.bun test(full),bun run build,bun run lintall green.🤖 Generated with Claude Code