Skip to content

Conversation

@Mustafabharmal
Copy link
Contributor

What?

Fixes #74884

The Content block disappearing from List View when changing a page's URL slug while "Show template" is enabled on block themes.

Why?

When editing a page with "Show template" enabled and changing the URL slug:

  • The Content block would disappear from the Document Overview (List View)
  • This only occurred on block themes like Twenty Twenty-Five

Root Cause:
The getTemplateId() selector in core-data uses the page slug to determine which template to display. When the slug changed, the selector would:

  1. Immediately look for a slug-specific template (e.g., page-new-slug)
  2. If not found, would temporarily return undefined
  3. This caused the Editor component to re-render without a template
  4. The re-render cleared the blocks from List View, losing the Content block

How?

Modified getTemplateId() in packages/core-data/src/private-selectors.ts to implement proper fallback logic:

Before: Attempted to find slug-specific template in a single call, which could return undefined
After: Two-step approach:

  1. Try slug-specific template first (e.g., page-about, single-post-hello-world)
  2. If not found or slug unavailable, immediately fall back to generic template (e.g., page, single-post)

This ensures the function always returns a valid template ID, preventing undefined states that cause the Content block to disappear.

Testing Instructions

  1. Use a block theme (e.g., Twenty Twenty-Five)
  2. Edit any page/post
  3. Enable "Show template" from the Options menu (⋮)
  4. Add some content to the page
  5. Open Document Overview (List View)
  6. In the sidebar, change the page's URL slug
  7. Content block should remain visible in List View
  8. Page content should remain editable

Screenshots or screencast

Before:

Screen.Recording.2026-01-23.at.5.09.45.PM.mov

After:

Screen.Recording.2026-01-23.at.5.12.08.PM.mov

@github-actions
Copy link

Warning: Type of PR label mismatch

To merge this PR, it requires exactly 1 label indicating the type of PR. Other labels are optional and not being checked here.

  • Required label: Any label starting with [Type].
  • Labels found: .

Read more about Type labels in Gutenberg. Don't worry if you don't have the required permissions to add labels; the PR reviewer should be able to help with the task.

@github-actions
Copy link

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: Mustafabharmal <mustafabharmal@git.wordpress.org>
Co-authored-by: jordesign <jordesign@git.wordpress.org>

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

@github-actions github-actions bot added the [Package] Core data /packages/core-data label Jan 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Package] Core data /packages/core-data

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Editing page slug while 'Show Template' is active causes content blocks to disappear from List View

1 participant