Skip to content

Jump to field on click#54

Open
muzzwood wants to merge 3 commits into
masterfrom
jump-to-field-on-click
Open

Jump to field on click#54
muzzwood wants to merge 3 commits into
masterfrom
jump-to-field-on-click

Conversation

@muzzwood

@muzzwood muzzwood commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

When an element is clicked on in the preview, if it's the output of a ContentBlocks field, the resource edit form in the manager will automatically scroll to it. And switch tabs if not on the right one.

Currently this only applies to ContentBlocks fields, I can't get it to reliably work with core resource fields yet.

Scrolling caused some issues when the draft panel was visible so the draft panel has been moved to above the ExtJS layout which gets recalculated to prevent some overflow at the bottom of the form being hidden.

This functionality requires some data attributes to be injected into ContentBlocks output via a new event within the preview. So it'll only work with an upcoming CB release.

muzzwood added 2 commits June 12, 2026 23:12
The banner is now appended to document.body as a fixed element (top: 0),
sitting entirely outside the ExtJS layout. CSS :has() selectors push the
MODX layout panels below it; relayoutModx() overrides getViewSize() on
the ExtJS Viewport to subtract the banner height so inner panel bodies
are not clipped. The race condition in the setTimeout cleanup path is
also fixed: recompute fresh DOM state inside the callback and add the
missing else-if branch to restore getViewSize when both panel and banner
are gone.
Clicking a data-magicpreview-field element in the preview iframe sends a
postMessage to the manager. The manager scrolls the resource form to the
matching ContentBlocks field (data-field attribute), activates its tab if
needed, focuses the element, and briefly highlights it with a blue outline
that fades via CSS transition. Window mode is supported via a relay listener
in preview.tpl that forwards messages from the frontend iframe to the
manager via window.opener.
@muzzwood muzzwood linked an issue Jun 12, 2026 that may be closed by this pull request
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.

Feature idea: Scroll to the Field in Panel Preview?

1 participant