fix: lazy-load frontend panel assets on first toggle - #93
Conversation
…n assets not loaded The button was dispatching a custom DOM event that had no listener because the overlay JS is only enqueued when ?slashed-frontend-panel is in the URL. Now the button navigates to the current URL with the query param when the panel is inactive, and falls back to the toggle event when it is already loaded. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DehHEfopxfkGpyN3tRmys8
The AppOverlay source had the save button repositioned before undo/redo in commit b071a99, but the compiled assets were never rebuilt — the deployed app.js still reflected the old button order. Rebuilding now includes the corrected header layout and all subsequent source changes (reset-all confirmation dialog, page-squeeze margin effect, aria-label on save button). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DehHEfopxfkGpyN3tRmys8
|
Warning Review limit reached
Next review available in: 55 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (3)
📝 WalkthroughWalkthroughThe ChangesAdmin-bar Design node conditional toggle
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
PR Summary by QodoLazy-load frontend design panel assets on first toggle Description
Diagram
High-Level Assessment
Files changed (3)
|
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@SLASHED-for-WP/includes/class-frontend-configurator.php`:
- Around line 117-123: The readiness check in the frontend configurator is using
the query parameter too early, which makes the admin-bar toggle link become a
no-op before the overlay listener is mounted. Update the logic in the frontend
configurator branch that sets the link target so it keeps a real navigation
fallback until the frontend is actually ready, or only returns false when a
client-side readiness flag indicates the `slashed:toggle-overlay` handler is
mounted. Use the existing frontend configurator path and the admin-bar link
setup that currently assigns `$href` and `$onclick` to locate the change.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: af27efc3-108c-4ab8-9163-b95dc183771e
📒 Files selected for processing (3)
SLASHED-for-WP/assets/admin-app/app.cssSLASHED-for-WP/assets/admin-app/app.jsSLASHED-for-WP/includes/class-frontend-configurator.php
…allback The admin-bar button was setting href="#" and return false as soon as ?slashed-frontend-panel was in the URL, but plugin-main.ts defers mount() until the overlay CSS loads (up to 5 s). Any click during that window dispatched slashed:toggle-overlay to no listener and blocked navigation — a silent no-op. Fix: plugin-main.ts now sets data-slashed-ready on the mount container after mount() succeeds. The PHP onclick checks for this attribute and only dispatches the event + prevents default when it is present. When absent, default navigation follows the real URL (current page with the query param), triggering a reload that lands on a fully-mounted panel. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DehHEfopxfkGpyN3tRmys8
Summary
Improves the frontend panel initialization by deferring asset loading until the user first toggles the design panel. When the panel assets haven't been loaded yet, clicking the "/ Design" button now navigates to the current URL with a
?slashed-frontend-panelquery parameter, which triggers asset injection on page load. Once loaded, subsequent toggles use a custom DOM event to avoid page reloads.This reduces initial page load overhead by only loading panel assets when needed, while maintaining a seamless UX after the first toggle.
Type
Checklist
feat:,fix:,docs:, …)npm testpassesnpm run lintpasses (stylelint +php -l)npm run verifypasses (version metadata in sync)dist/,data/inventory.json,data/classes-hints.jsoncome fromupdate-framework/build:data)CHANGELOG.mdupdated under## [Unreleased](for user-facing changes)editor-app/admin-appsource changedNotes
The logic now checks for the presence of the
slashed-frontend-panelquery parameter to determine whether assets are already loaded:#with custom event dispatcher in onclick handlerThis maintains backward compatibility while optimizing initial page load performance.
https://claude.ai/code/session_01DehHEfopxfkGpyN3tRmys8
Summary by CodeRabbit