Skip to content

Address viewport placeholder review feedback - #29

Merged
roborourke merged 1 commit into
mainfrom
claude/query-loop-viewport-placeholder-dh2yld
Jul 27, 2026
Merged

Address viewport placeholder review feedback#29
roborourke merged 1 commit into
mainfrom
claude/query-loop-viewport-placeholder-dh2yld

Conversation

@roborourke

Copy link
Copy Markdown
Collaborator

Summary

Follow-up to the merged #27, addressing @kadamwhite's post-merge review of the viewport-placeholder code. Two changes, no behavior change.

Changes

Rules of hooks (review comment)

withViewportPlaceholder called useState / useSelect / useEffect after the HOC's early return for non-core/query blocks — a rules-of-hooks violation (it worked in practice only because name is stable per block instance). Everything after the early return is now extracted into a LazyBlockEdit component whose hooks run unconditionally, so the HOC reduces to:

createHigherOrderComponent( ( BlockEdit ) => {
	return ( props ) => {
		if ( props.name !== 'core/query' ) {
			return <BlockEdit { ...props } />;
		}

		return <LazyBlockEdit BlockEdit={ BlockEdit } { ...props } />;
	};
}, 'withViewportPlaceholder' );

Trim the doc block (review comment)

Applied KAdam's suggested tighter wording for the QueryLoopPlaceholder doc block, which conveys the same information more directly.

Testing

  • npm run build — compiles cleanly.
  • npm run lint:js — clean.
  • The existing tests/e2e/viewport-placeholder.spec.js coverage is unchanged, since behavior is identical.

🤖 Generated with Claude Code


Generated by Claude Code

Follow-up to the merged #27, addressing KAdam's review:

- Extract LazyBlockEdit so the placeholder hooks (useState, useSelect,
  useEffect) are no longer called after the HOC's early return for
  non-query blocks, satisfying the rules of hooks.
- Tighten the QueryLoopPlaceholder doc block.

No behavior change.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EAvqR2G3Q3aJkTtePzmLg7
@roborourke
roborourke requested a review from kadamwhite July 24, 2026 15:08
@github-actions

Copy link
Copy Markdown

Playwright test results

passed  22 passed

Details

stats  22 tests across 7 suites
duration  1 minute, 20 seconds
commit  e0a0fe5

@roborourke
roborourke marked this pull request as ready for review July 27, 2026 09:36
@roborourke
roborourke requested a review from mattheu July 27, 2026 09:36

@svandragt svandragt left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting to think if that's possible for all blocks loading lazily.

@roborourke

Copy link
Copy Markdown
Collaborator Author

Potentially. Are there other blocks that are heavy on requests you can think of?

@roborourke
roborourke merged commit 3fcda25 into main Jul 27, 2026
1 check passed
@roborourke
roborourke deleted the claude/query-loop-viewport-placeholder-dh2yld branch July 27, 2026 14:10
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