Skip to content

Editor: Hide parent controls for non-hierarchical post types - #85679

Merged
oandregal merged 5 commits into
WordPress:trunkfrom
drewmt:fix/non-hierarchical-parent-summary
Nov 20, 2026
Merged

oandregal merged 5 commits into
WordPress:trunkfrom
drewmt:fix/non-hierarchical-parent-summary

Conversation

@drewmt

@drewmt drewmt commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

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-attributes gives a post type both menu_order and a parent. A non-hierarchical post type often adds it only for menu_order, but it can't have a parent: WordPress core's classic meta box and the REST API (parent property) both require hierarchical. 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 the parent field only for post types that are hierarchical and support page-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 the field.php definition 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 exported PageAttributesPanel returns null for non-hierarchical post types. The editor's sidebar no longer renders it, but plugins can.
  • Changelog entries for @wordpress/core-fields and @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

  1. Activate the gutenberg-test-custom-post-types plugin.
  2. Add a Non-Hierarchical post (hierarchical => false, supports page-attributes) and open the summary in the settings sidebar. There's no Parent row.
  3. Add a Hierarchical Private post (hierarchical => true, public => false, supports page-attributes). The Parent row is there, and its popover shows the Parent combobox.
  4. Add a Hierarchical No Title post and publish it. Add another one, pick the first as its parent, publish and reload: the parent is kept. Pages still have their Parent control.

Automated coverage:

  • PHPUnit Tests_Entity_Fields_API: the parent field across the four combinations of hierarchy and page-attributes support.
  • Vitest packages/editor/src/components/page-attributes/test/panel.jsdom.test.tsx: the panel for hierarchical, non-hierarchical, loading and disabled states.
  • Playwright 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 the edit.tsx change.

Testing Instructions for Keyboard

  1. In the Non-Hierarchical post, Tab through the summary: there's no Parent control.
  2. In the Hierarchical Private post, Tab to "Edit Parent" and press Enter: the Parent combobox opens and takes focus. Press Escape to close the popover.

Screenshots or screencast

Before After
A non-hierarchical post type shows "Parent: None" with an empty popover. No Parent row. Hierarchical post types, viewable or not, get a working Parent control.

Use of AI Tools

Claude Code (Claude Opus 5.5) was used for the edit.tsx change, the hierarchical private post type and its test, the rebase onto trunk, and this description.

@github-actions github-actions Bot added [Package] Editor /packages/editor [Package] E2E Tests /packages/e2e-tests [Package] Fields /packages/fields labels Oct 26, 2026
@github-actions

github-actions Bot commented Oct 26, 2026 •

Copy link
Copy Markdown

🤖 PR meta 🤖

Preview in WordPress Playground

🎉 Props

Unlinked Accounts

The 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.

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>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.


Props Bot commands

You can trigger Props Bot actions by commenting on this PR:

  • @propsbot add <username> to give props to a GitHub user. Requires write access.
  • @propsbot remove <username> to leave a user out of the props. Requires write access.
  • @propsbot refresh to refresh this list. Adding the props-bot label works too.

Updated as activity occurs, without notifying anyone named here. Add the props-bot label to refresh.

@drewmt drewmt changed the title Hide parent controls for non-hierarchical post types Editor: Hide parent controls for non-hierarchical post types Oct 26, 2026
} );

await expect(
summary.getByText( 'Parent', { exact: true } )

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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();?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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' ),

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

A hierarchical private post type showing Parent None with a popover that only has the help text

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@jorgefilipecosta

Copy link
Copy Markdown
Member

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 @wordpress/editor changelog entry ends up under the already published 16.1.0 section, so it should be moved back to Unreleased. The two inline comments are not blockers.

}, [] );

if ( ! isEnabled || ! postType ) {
if ( ! isEnabled || ! postType?.hierarchical ) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not strictly necessary as this panel is no longer in use. Though, it doesn't hurt adding it.

@oandregal oandregal added Backport to WP 7.2 Beta/RC Pull request that needs to be backported to the WordPress major release that's currently in beta [Type] Bug An existing feature does not function as intended labels Nov 20, 2026
oandregal added a commit to drewmt/wordpress-develop that referenced this pull request Nov 20, 2026
Its definition still described the support-only condition. Matches
WordPress/gutenberg#85679.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
drewmt and others added 5 commits November 20, 2026 12:57
…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>
@oandregal
oandregal force-pushed the fix/non-hierarchical-parent-summary branch from c2287a5 to 6ffee14 Compare November 20, 2026 11:58

@oandregal oandregal left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your work, @drewmt

@oandregal
oandregal merged commit 728dd7e into WordPress:trunk Nov 20, 2026
93 checks passed
@github-actions github-actions Bot added this to the Gutenberg 24.6 milestone Nov 20, 2026
@github-actions

Copy link
Copy Markdown

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.

# Checkout the wp/7.2 branch instead of trunk.
git checkout wp/7.2

# Create a new branch for your PR.
git checkout -b my-branch

# Cherry-pick the commit.
git cherry-pick 728dd7ea968bc99ebe575c0ceb045a8e60368f4b

# Check which files have conflicts.
git status

# Resolve the conflict...
# Add the resolved files to the staging area.
git status
git add .
git cherry-pick --continue

# Push the branch to the repository
git push origin my-branch

# Create a PR and set the base to the wp/7.2 branch.
# See https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/changing-the-base-branch-of-a-pull-request.

oandregal added a commit to drewmt/wordpress-develop that referenced this pull request Nov 20, 2026
Its definition still described the support-only condition. Matches
WordPress/gutenberg#85679.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@oandregal

Copy link
Copy Markdown
Member

Backport pr at #87150

oandregal added a commit that referenced this pull request Nov 20, 2026
…#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>
@t-hamano t-hamano removed the Backport to WP 7.2 Beta/RC Pull request that needs to be backported to the WordPress major release that's currently in beta label Nov 23, 2026
@t-hamano t-hamano added the Backported to WP Core Pull request that has been successfully merged into WP Core label Nov 23, 2026
wporg-sync pushed a commit to WordPress/wordpress-develop that referenced this pull request Nov 24, 2026
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
wporg-sync pushed a commit to WordPress/WordPress that referenced this pull request Nov 24, 2026
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Backported to WP Core Pull request that has been successfully merged into WP Core [Package] E2E Tests /packages/e2e-tests [Package] Editor /packages/editor [Package] Fields /packages/fields [Type] Bug An existing feature does not function as intended

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Post summary shows "Parent: None" for non-hierarchical post types that support page-attributes

4 participants