feat(components): addToolbarBackButton util in newspack-components#4619
feat(components): addToolbarBackButton util in newspack-components#4619
Conversation
There was a problem hiding this comment.
Pull request overview
This PR introduces a reusable utility for injecting a “back” button into the WordPress block editor toolbar (via DOM manipulation), and updates admin redirects to prevent accessing the core post list UI for gate layout posts.
Changes:
- Add
addToolbarBackButtonutility innewspack-componentsto render a back button in the editor toolbar. - Use the new utility in the content gate layout editor to link back to the Access Control wizard.
- Redirect
edit.php?post_type=np_gate_layout(and gates) away from the core post list screen to the appropriate wizard page.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 8 comments.
| File | Description |
|---|---|
src/content-gate/editor/editor.js |
Calls the new toolbar back button utility from the gate layout editor UI. |
packages/components/src/utils/editor-toolbar-back-button.tsx |
Implements the DOM + React-root injection utility for the editor toolbar back button. |
includes/content-gate/class-content-gate.php |
Expands CPT list-screen redirects to include gate layouts and adjusts target based on Memberships state. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Ah, that's in full-screen only mode, right? What if we just hid our custom one in full-screen mode? I think the main issue we're trying to solve is that Core's back button only appears in full-screen mode, so without that there's no back button. |
|
@thomasguillot fb7497d hides the custom back button when the editor is in full-screen mode, avoiding the double back button issue you mentioned. |

All Submissions:
Changes proposed in this Pull Request:
Adds a small utility function to the Newspack Components package that adds a back button to the WP block editor toolbar:
The util function relies on DOM manipulation because the WP block editor currently doesn't provide any filters or SlotFill areas to add elements to the editor toolbar. It's in the Components package so that it can be consumed and used in other Newspack repositories.
Also adds a redirect for the
wp-admin/edit.php?post_type=np_gate_layoutlink to redirect to the main Access Control wizard page, as the core post list UI shouldn't be accessible for gate layout posts.Closes NPPD-1393.
How to test the changes in this Pull Request:
Other information: