fix(block-theme): ensure Overlay Menu block panel opens in editor after template part switch#4642
Open
laurelfulford wants to merge 5 commits intotrunkfrom
Open
fix(block-theme): ensure Overlay Menu block panel opens in editor after template part switch#4642laurelfulford wants to merge 5 commits intotrunkfrom
laurelfulford wants to merge 5 commits intotrunkfrom
Conversation
6 tasks
Contributor
There was a problem hiding this comment.
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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:
Other information: