Skip to content

Add server-side rendered preview for unselected query loop blocks#11

Open
roborourke wants to merge 6 commits intomainfrom
claude/server-side-render-previews-1zFB5
Open

Add server-side rendered preview for unselected query loop blocks#11
roborourke wants to merge 6 commits intomainfrom
claude/server-side-render-previews-1zFB5

Conversation

@roborourke
Copy link
Collaborator

@roborourke roborourke commented Feb 12, 2026

Pages with many query loops (e.g. magazine homepages) trigger a large
number of API requests as each block loads its content previews. This
replaces the full editor rendering with a server-side rendered preview
when the query loop block is not selected, switching to the full editor
when the user clicks on it.

Registers a hidden hm-query-loop/preview block whose render_callback
runs do_blocks() on the serialized block markup. The editor uses
ServerSideRender with httpMethod="POST" to send the full inner blocks
content to this endpoint, wrapped in the Disabled component to prevent
interaction until the block is selected.

https://claude.ai/code/session_01LSHcKsEAo3tV17kuSFHTaj

Open WordPress Playground Preview

Pages with many query loops (e.g. magazine homepages) trigger a large
number of API requests as each block loads its content previews. This
replaces the full editor rendering with a server-side rendered preview
when the query loop block is not selected, switching to the full editor
when the user clicks on it.

Registers a hidden hm-query-loop/preview block whose render_callback
runs do_blocks() on the serialized block markup. The editor uses
ServerSideRender with httpMethod="POST" to send the full inner blocks
content to this endpoint, wrapped in the Disabled component to prevent
interaction until the block is selected.

https://claude.ai/code/session_01LSHcKsEAo3tV17kuSFHTaj
@github-actions
Copy link

github-actions bot commented Feb 12, 2026

Playwright test results

failed  2 failed
passed  10 passed

Details

stats  12 tests across 4 suites
duration  1 minute, 44 seconds
commit  31436e9

Failed tests

chromium › posts-per-page.spec.js › Posts Per Page Override › should reflect posts per page override in editor
chromium › posts-per-page.spec.js › Posts Per Page Override › should enforce max value from posts_per_page setting

The ServerSideRender component uses __experimentalSanitizeBlockAttributes
internally which requires the block to be registered in the JS block
registry. Add a minimal registerBlockType call for hm-query-loop/preview
with inserter: false so it resolves during attribute sanitization.

Remove the Disabled wrapper since ServerSideRender already renders
static HTML that doesn't need interaction prevention.

https://claude.ai/code/session_01LSHcKsEAo3tV17kuSFHTaj
Adds two GitHub Actions workflows adapted from hm-url-tabs:

- pr-playground-preview.yml: On PR open/sync, builds the plugin, pushes
  built assets to a pr-N-built branch, and appends a WordPress Playground
  preview button to the PR description using the official action.
- pr-cleanup.yml: Deletes the pr-N-built branch when the PR is closed.

https://claude.ai/code/session_01LSHcKsEAo3tV17kuSFHTaj
github-actions bot added a commit that referenced this pull request Feb 28, 2026
In the site editor, getCurrentPostId() can return a non-numeric
template identifier. Sending post_id=0 or a string also fails the
block-renderer endpoint's integer validation. Only include the
parameter when we have a real numeric post ID.

https://claude.ai/code/session_01LSHcKsEAo3tV17kuSFHTaj
github-actions bot added a commit that referenced this pull request Feb 28, 2026
The server-rendered HTML contains real anchor tags and other interactive
elements that would navigate the editor iframe when clicked. Wrapping
in the Disabled component prevents this.

https://claude.ai/code/session_01LSHcKsEAo3tV17kuSFHTaj
github-actions bot added a commit that referenced this pull request Feb 28, 2026
Two problems with the Disabled component wrapper:
- It changes the DOM structure so the query loop block can't be selected
  via click (the Disabled wrapper intercepts the event)
- Reverting to SSR preview on deselection triggers unnecessary re-fetches

Fix both by:
- Adding the inert attribute to top-level elements in the rendered HTML
  server-side using WP_HTML_Tag_Processor, preserving the original DOM
  structure so block selection works naturally
- Using useState to latch blocks as "activated" once first selected,
  keeping them in full edit mode permanently for the session

https://claude.ai/code/session_01LSHcKsEAo3tV17kuSFHTaj
github-actions bot added a commit that referenced this pull request Feb 28, 2026
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.

2 participants