Repository navigation
Editor: Hide parent controls for non-hierarchical post types - #85679
Conversation
🤖 PR meta 🤖🎉 PropsUnlinked AccountsThe following contributors have not linked their GitHub and WordPress.org accounts: @wojtekpiskorz. Contributors, please read how to link your accounts to ensure your work is properly credited in WordPress releases. If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. Props Bot commandsYou can trigger Props Bot actions by commenting on this PR:
Updated as activity occurs, without notifying anyone named here. Add the |
| } ); | ||
|
|
||
| await expect( | ||
| summary.getByText( 'Parent', { exact: true } ) |
There was a problem hiding this comment.
Minor non blocker: I think these two assertions can pass before the summary fields are rendered, because the summary container is visible before its rows and a count of zero is satisfied right away. Should we assert a row that must exist first, e.g: await expect( summary.getByText( 'Status', { exact: true } ) ).toBeVisible();?
There was a problem hiding this comment.
Updated in c29047a: merged trunk, moved the editor changelog entry back to Unreleased, and made the regression wait for the Status row before checking that Parent is absent. The build, focused typechecks, 4 unit tests and all 4 Chromium tests pass locally. I’ve kept the private hierarchical case separate to keep this PR focused.
| 'last_edited_date' => true, | ||
| 'notesCount' => is_array( $editor ) && (bool) array_filter( array_column( $editor, 'notes' ) ), | ||
| 'parent' => post_type_supports( $post_type, 'page-attributes' ), | ||
| 'parent' => is_post_type_hierarchical( $post_type ) && post_type_supports( $post_type, 'page-attributes' ), |
There was a problem hiding this comment.
The edit of the parent field still requires the post type to be viewable (https://github.com/WordPress/gutenberg/blob/trunk/packages/core-fields/src/post_type_supports/parent/edit.tsx#L120), so a hierarchical post type with public => false and page attributes keeps the empty Parent row this PR removes for flat types. Should we use the same condition in both places, e.g: drop the viewable check in the edit, as the previous panel did not require it? This can also be a follow-up if you prefer to keep this PR focused on #85595.
There was a problem hiding this comment.
Yeah, this is important to address as well. Given the time sensitivity of this issue (we'll want to backport it to WordPress 7.2 RC), I'll go ahead and push the tweak directly to minimize back-and-forth.
|
Things tested well and the code looks good 👍 I think we just need two minor fixes before the merge. The branch needs an update from trunk, as the "Required changes from trunk" check is failing. After that update the |
| }, [] ); | ||
|
|
||
| if ( ! isEnabled || ! postType ) { | ||
| if ( ! isEnabled || ! postType?.hierarchical ) { |
There was a problem hiding this comment.
This is not strictly necessary as this panel is no longer in use. Though, it doesn't hurt adding it.
Its definition still described the support-only condition. Matches WordPress/gutenberg#85679. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…st types The server registers the parent field for every hierarchical post type supporting page attributes, but its edit required the post type to be viewable too. A hierarchical post type with `public => false` got the Parent row and an empty popover. Require hierarchy only, as the server and the previous page attributes panel do. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Its definition still described the support-only condition. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
c2287a5 to
6ffee14
Compare
|
There was a conflict while trying to cherry-pick the commit to the wp/7.2 branch. Please resolve the conflict manually and create a PR to the wp/7.2 branch. PRs to wp/7.2 are similar to PRs to trunk, but you should base your PR on the wp/7.2 branch instead of trunk. |
Its definition still described the support-only condition. Matches WordPress/gutenberg#85679. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Backport pr at #87150 |
…#87150) Unlinked contributors: wojtekpiskorz. Co-authored-by: drewmt <linewebdigital@git.wordpress.org> Co-authored-by: oandregal <oandregal@git.wordpress.org> Co-authored-by: jorgefilipecosta <jorgefilipecosta@git.wordpress.org> Co-authored-by: singhakanshu00 <akanshusingh@git.wordpress.org> Co-authored-by: Mamaduka <mamaduka@git.wordpress.org>
This updates the pinned commit hash of the Gutenberg repository from `efd7722f89ebb8abfc3607fffdd86f5e34afbd9c` to `c5bdc7f4898ec98114cdccbe1cacec7a979b85cc` (head of the `wp/7.2` branch). A full list of changes included in this commit can be found on GitHub: WordPress/gutenberg@efd7722...c5bdc7f. - Interactivity API: Align unsupported `data-wp-html` bindings with PHP (WordPress/gutenberg#86968) (WordPress/gutenberg#87015) - E2E: Select the link preview by URL in the keyboard test (WordPress/gutenberg#87053) (WordPress/gutenberg#87102) - Update the Update icon. (WordPress/gutenberg#87088) (WordPress/gutenberg#87139) - Editor: Hide parent controls for non-hierarchical post types (WordPress/gutenberg#85679) (WordPress/gutenberg#87150) - SearchableChipSelect: Use a single string for the chips toolbar label (WordPress/gutenberg#87219) (WordPress/gutenberg#87275) - E2E Tests: Switch the theme before the other setup resets (WordPress/gutenberg#86278) - Abilities: Accept a date-time without an offset in the `date-time` schema format (WordPress/gutenberg#86845) (WordPress/gutenberg#87311) - Fix iOS tap into a quote jumping to the caret's block when it's off screen (WordPress/gutenberg#86923) - Place the caret on a tap after the keyboard is swiped away (WordPress/gutenberg#87182) - Writing flow: Keep the browser from deleting into a neighbouring block (WordPress/gutenberg#87188) - Writing flow: Bring back the header iOS slides off screen, once the canvas stops scrolling (WordPress/gutenberg#87316) - List: Drag a list item by its bullet again (WordPress/gutenberg#85801) - MediaEdit: Show the image preview when the MIME type is empty (WordPress/gutenberg#87207) (WordPress/gutenberg#87326) - Block Editor: Fix block hover outline flicker when moving between elements of a block (WordPress/gutenberg#86852) (WordPress/gutenberg#87328) Developed in: #16187 Props peterwilsoncc, mamaduka, linewebdigital, abhishekfdd, oandregal, jorgefilipecosta. See #66340. Fixes #66428. git-svn-id: https://develop.svn.wordpress.org/trunk@65751 602fd350-edb4-49c9-b593-d223f7449a82
This updates the pinned commit hash of the Gutenberg repository from `efd7722f89ebb8abfc3607fffdd86f5e34afbd9c` to `c5bdc7f4898ec98114cdccbe1cacec7a979b85cc` (head of the `wp/7.2` branch). A full list of changes included in this commit can be found on GitHub: WordPress/gutenberg@efd7722...c5bdc7f. - Interactivity API: Align unsupported `data-wp-html` bindings with PHP (WordPress/gutenberg#86968) (WordPress/gutenberg#87015) - E2E: Select the link preview by URL in the keyboard test (WordPress/gutenberg#87053) (WordPress/gutenberg#87102) - Update the Update icon. (WordPress/gutenberg#87088) (WordPress/gutenberg#87139) - Editor: Hide parent controls for non-hierarchical post types (WordPress/gutenberg#85679) (WordPress/gutenberg#87150) - SearchableChipSelect: Use a single string for the chips toolbar label (WordPress/gutenberg#87219) (WordPress/gutenberg#87275) - E2E Tests: Switch the theme before the other setup resets (WordPress/gutenberg#86278) - Abilities: Accept a date-time without an offset in the `date-time` schema format (WordPress/gutenberg#86845) (WordPress/gutenberg#87311) - Fix iOS tap into a quote jumping to the caret's block when it's off screen (WordPress/gutenberg#86923) - Place the caret on a tap after the keyboard is swiped away (WordPress/gutenberg#87182) - Writing flow: Keep the browser from deleting into a neighbouring block (WordPress/gutenberg#87188) - Writing flow: Bring back the header iOS slides off screen, once the canvas stops scrolling (WordPress/gutenberg#87316) - List: Drag a list item by its bullet again (WordPress/gutenberg#85801) - MediaEdit: Show the image preview when the MIME type is empty (WordPress/gutenberg#87207) (WordPress/gutenberg#87326) - Block Editor: Fix block hover outline flicker when moving between elements of a block (WordPress/gutenberg#86852) (WordPress/gutenberg#87328) Developed in: WordPress/wordpress-develop#16187 Props peterwilsoncc, mamaduka, linewebdigital, abhishekfdd, oandregal, jorgefilipecosta. See #66340. Fixes #66428. Built from https://develop.svn.wordpress.org/trunk@65751 git-svn-id: http://core.svn.wordpress.org/trunk@64781 1a063a9b-81f0-0310-95a4-ce76da25c4cd

What?
Closes #85595.
Hide the Parent field for non-hierarchical post types that support
page-attributes, and show a working Parent control for hierarchical post types that aren't publicly viewable.Why?
page-attributesgives a post type bothmenu_orderand a parent. A non-hierarchical post type often adds it only formenu_order, but it can't have a parent: WordPress core's classic meta box and the REST API (parentproperty) both requirehierarchical. The post summary showed such post types a "Parent: None" row whose popover had no field in it.The same empty row showed for hierarchical post types with
public => false: the server registered the field, but its edit also required the post type to be viewable, so it rendered nothing.How?
packages/core-fields/src/index.php: register theparentfield only for post types that are hierarchical and supportpage-attributes. The field registry feeds the post summary, Quick Edit and the extensible site editor, so this one condition covers all of them. The docblock, the README and thefield.phpdefinition say so too.packages/core-fields/src/post_type_supports/parent/edit.tsx: require hierarchy only, not hierarchy and viewability, so the edit agrees with the server and with the previous page attributes panel.packages/editor/src/components/page-attributes/panel.jsx: the exportedPageAttributesPanelreturnsnullfor non-hierarchical post types. The editor's sidebar no longer renders it, but plugins can.@wordpress/core-fieldsand@wordpress/editor, and a backport-changelog entry for Entity Fields: Require hierarchy for the parent field wordpress-develop#15290. The JavaScript change has no tracked file in Core; it arrives with the Gutenberg build.Testing Instructions
gutenberg-test-custom-post-typesplugin.hierarchical => false, supportspage-attributes) and open the summary in the settings sidebar. There's no Parent row.hierarchical => true,public => false, supportspage-attributes). The Parent row is there, and its popover shows the Parent combobox.Automated coverage:
Tests_Entity_Fields_API: the parent field across the four combinations of hierarchy andpage-attributessupport.packages/editor/src/components/page-attributes/test/panel.jsdom.test.tsx: the panel for hierarchical, non-hierarchical, loading and disabled states.test/e2e/specs/editor/plugins/custom-post-types.spec.js: no Parent row for the non-hierarchical post type, and a working Parent combobox for the hierarchical private one. The latter fails without theedit.tsxchange.Testing Instructions for Keyboard
Screenshots or screencast
Use of AI Tools
Claude Code (Claude Opus 5.5) was used for the
edit.tsxchange, the hierarchical private post type and its test, the rebase onto trunk, and this description.