Skip to content

fix(block-theme): ensure Overlay Menu block panel opens in editor after template part switch#4642

Open
laurelfulford wants to merge 5 commits intotrunkfrom
fix/overlay-menu-register-toggle-during-render
Open

fix(block-theme): ensure Overlay Menu block panel opens in editor after template part switch#4642
laurelfulford wants to merge 5 commits intotrunkfrom
fix/overlay-menu-register-toggle-during-render

Conversation

@laurelfulford
Copy link
Copy Markdown
Contributor

@laurelfulford laurelfulford commented Apr 7, 2026

All Submissions:

Changes proposed in this Pull Request:

This PR cleans up an issue I noticed adding the block to the block theme:

The 'Open Panel' button in the main block, button trigger block, and panel block should all open/close the panel. This wasn't working after switching template parts in the site editor. This was a timing thing overall -- the method the parent and trigger block were using to find the panel was returning empty while the editor was still loading.

It should be tested alongside Automattic/newspack-block-theme#438, which has the block added to different template parts you can swap between.

How to test the changes in this Pull Request:

  1. Apply this PR.
  2. Test in a setup where the Overlay Menu block is in at least one of your available header template parts (like in feat: swap in Overlay Menu block to replace template parts newspack-block-theme#438)
  3. Switch the header template part to one with the Overlay Menu block.
  4. Ensure that the "Open Panel" button in the Menu Trigger block, Overlay parent block, and Overlay Panel block all open/close the panel in the editor.

Other information:

  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you written new tests for your changes, as applicable?
  • Have you successfully ran tests with your changes locally?

Copy link
Copy Markdown
Contributor

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 fixes editor preview toggling for the Overlay Menu block so the “Open panel” toolbar button continues to work reliably after switching template parts in the Site Editor, by changing how the panel toggle function and open-state subscriptions are keyed and looked up.

Changes:

  • Switch preview toggle/subscription keys from the panel block clientId to the parent Overlay Menu block’s clientId.
  • Update the parent and trigger blocks to subscribe/toggle using the parent clientId rather than searching for the panel sibling/child.
  • Update the panel block to register its toggle under the parent clientId and notify subscribers using that same key.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 5 comments.

File Description
src/blocks/overlay-menu/edit.js Parent now subscribes/toggles preview state using its own clientId (the new shared key).
src/blocks/overlay-menu/trigger/edit.js Trigger now derives parentClientId via getBlockRootClientId and uses it for subscribing/toggling.
src/blocks/overlay-menu/panel/edit.js Panel now derives parentClientId and registers/notifies preview state using the parent key.

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

@laurelfulford laurelfulford marked this pull request as ready for review April 7, 2026 23:33
@laurelfulford laurelfulford requested a review from a team as a code owner April 7, 2026 23:33
@laurelfulford laurelfulford added the [Status] Needs Review The issue or pull request needs to be reviewed label Apr 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Status] Needs Review The issue or pull request needs to be reviewed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants