Skip to content

Refactor Preview component#2772

Open
girishpanchal30 wants to merge 2 commits intodevelopmentfrom
bugfix/2615
Open

Refactor Preview component#2772
girishpanchal30 wants to merge 2 commits intodevelopmentfrom
bugfix/2615

Conversation

@girishpanchal30
Copy link
Copy Markdown
Contributor

Closes #2615

Summary

Preview was moved to module scope (outside Edit), making its reference stable across renders. Since isLoading was previously captured via closure, it is now passed as an explicit prop.

Checklist before the final review

  • Included E2E or unit tests for the changes in this PR.
  • Visual elements are not affected by independent changes.
  • It is at least compatible with the minimum WordPress version.
  • It loads additional script in frontend only if it is required.
  • Does not impact the Core Web Vitals.
  • In case of deprecation, old blocks are safely migrated.
  • It is usable in Widgets and FSE.
  • Copy/Paste is working if the attributes are modified.
  • PR is following the best practices

@girishpanchal30 girishpanchal30 requested a review from Copilot April 7, 2026 13:18
@girishpanchal30 girishpanchal30 added the pr-checklist-skip Allow this Pull Request to skip checklist. label Apr 7, 2026
@pirate-bot pirate-bot added the pr-checklist-complete The Pull Request checklist is complete. (automatic label) label Apr 7, 2026
@girishpanchal30 girishpanchal30 linked an issue Apr 7, 2026 that may be closed by this pull request
@girishpanchal30 girishpanchal30 changed the title fix: refactor Preview component Refactor Preview component Apr 7, 2026
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR refactors the Posts block editor implementation by moving the Preview component to module scope so its reference is stable across Edit re-renders, and updates Preview to receive isLoading explicitly rather than via closure. This aligns with the goal of reducing editor oddities (like animation behavior) caused by component identity changes.

Changes:

  • Hoisted Preview out of Edit to keep a stable component reference across renders.
  • Passed isLoading as an explicit prop to Preview.
  • Kept existing loading/empty-state handling and preview rendering structure intact.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@pirate-bot
Copy link
Copy Markdown
Contributor

pirate-bot commented Apr 7, 2026

Bundle Size Diff

Package Old Size New Size Diff
Animations 276.77 KB 276.77 KB 0 B (0.00%)
Blocks 1.55 MB 1.55 MB 95 B (0.01%)
CSS 105.9 KB 105.9 KB 0 B (0.00%)
Dashboard 204.08 KB 204.08 KB 0 B (0.00%)
Onboarding 165.94 KB 165.94 KB 0 B (0.00%)
Export Import 102.86 KB 102.86 KB 0 B (0.00%)
Pro 412.55 KB 412.55 KB 0 B (0.00%)

@pirate-bot
Copy link
Copy Markdown
Contributor

pirate-bot commented Apr 7, 2026

Plugin build for bc72dc2 is ready 🛎️!

@pirate-bot
Copy link
Copy Markdown
Contributor

E2E Tests

Playwright Test Status:

Performance Results serverResponse: {"q25":362,"q50":366.2,"q75":397.2,"cnt":10}, firstPaint: {"q25":370.4,"q50":387.3,"q75":515.6,"cnt":10}, domContentLoaded: {"q25":1586.3,"q50":1600.5,"q75":1610.7,"cnt":10}, loaded: {"q25":1586.6,"q50":1600.9,"q75":1611,"cnt":10}, firstContentfulPaint: {"q25":3208.6,"q50":3228.4,"q75":3240.8,"cnt":10}, firstBlock: {"q25":6565.7,"q50":6576.2,"q75":6622.8,"cnt":10}, type: {"q25":12.5,"q50":12.53,"q75":13.91,"cnt":10}, typeWithoutInspector: {"q25":11.18,"q50":11.69,"q75":12.21,"cnt":10}, typeWithTopToolbar: {"q25":14.06,"q50":14.74,"q75":16.35,"cnt":10}, typeContainer: {"q25":6.96,"q50":7.4,"q75":7.81,"cnt":10}, focus: {"q25":49.65,"q50":50.91,"q75":53.98,"cnt":10}, inserterOpen: {"q25":16.31,"q50":17.28,"q75":18.24,"cnt":10}, inserterSearch: {"q25":5.64,"q50":5.76,"q75":6.21,"cnt":10}, inserterHover: {"q25":2.5,"q50":2.59,"q75":2.71,"cnt":20}, loadPatterns: {"q25":1015.46,"q50":1054.19,"q75":1085.03,"cnt":10}, listViewOpen: {"q25":77.52,"q50":79.82,"q75":91.1,"cnt":10}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-checklist-complete The Pull Request checklist is complete. (automatic label) pr-checklist-skip Allow this Pull Request to skip checklist.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Animations on the Posts block act weird in the editor

4 participants