Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Block editor: Can not edit slug with "Show template" enabled #69509

Closed
3 of 6 tasks
carolinan opened this issue Mar 10, 2025 · 4 comments · Fixed by #69516
Closed
3 of 6 tasks

Block editor: Can not edit slug with "Show template" enabled #69509

carolinan opened this issue Mar 10, 2025 · 4 comments · Fixed by #69516
Assignees
Labels
[Package] Editor /packages/editor [Type] Bug An existing feature does not function as intended

Comments

@carolinan
Copy link
Contributor

carolinan commented Mar 10, 2025

Description

When editing a page or post in the block editor, and "Show template" is enabled,
I can not edit the slug correctly due to a bug.

A soon as I enter a character into the slug input field in the popover, the change is saved and the page "refreshes":
The page content becomes blank for a moment until the blocks shows again, and the popover is closed.
So, I can only enter one character at the time.

This happens with Gutenberg trunk enabled.
In 6.8 beta, without Gutenberg active, the canvas blinks and refreshes when I enter each character into the slug field. But the popover does not close, so I can continue entering my updated slug into the field.

Step-by-step reproduction instructions

Activate a block theme.
Create or edit a page or post in the block editor.

Enable "show template".
Open the document panel.
Open the slug popover by clicking on the link next to the text "Slug"
Try entering a long slug.

Screenshots, screen recording, code snippet

With Gutenberg active:

page-slug.mp4

Environment info

No response

Please confirm that you have searched existing issues in the repo.

  • Yes

Please confirm that you have tested with all plugins deactivated except Gutenberg.

  • Yes

Please confirm which theme type you used for testing.

  • Block
  • Classic
  • Hybrid (e.g. classic with theme.json)
  • Not sure
@carolinan carolinan added the [Type] Bug An existing feature does not function as intended label Mar 10, 2025
@carolinan
Copy link
Contributor Author

If I assign a different template than the default "page" template, this bug does not happen, entering the slug works:

Activate Twenty Twenty-Five
Create a new page.
Add a title.
In the template section in the document panel, assign the page template "page no title".
Save.
Try editing the slug.

In the template section in the document panel, select "create new template".
Save.
Try editing the slug.

@Mamaduka Mamaduka added the [Package] Editor /packages/editor label Mar 10, 2025
@Mamaduka Mamaduka self-assigned this Mar 10, 2025
@Mamaduka Mamaduka moved this to 📥 Todo in WordPress 6.8 Editor Tasks Mar 10, 2025
@carolinan
Copy link
Contributor Author

If zoom out is enabled when you try to edit the slug, the zoom out is disabled when you start typing, but the option in the toolbar still shows it as enabled.

@Mamaduka
Copy link
Member

Thanks for testing this feature, @carolinan!

In 6.8 beta, without Gutenberg active, the canvas blinks and refreshes when I enter each character into the slug field. But the popover does not close, so I can continue entering my updated slug into the field.

I'm getting the same behavior here. We've not shipped anything for this logic since Beta 1.

The problem comes from this part of the selector since changing the post type slug also affects potential template ID resolution.

// If no template is assigned, use the default template.
let slugToCheck;
// In `draft` status we might not have a slug available, so we use the `single`
// post type templates slug(ex page, single-post, single-product etc..).
// Pages do not need the `single` prefix in the slug to be prioritized
// through template hierarchy.
if ( editedEntity.slug ) {
slugToCheck =
postType === 'page'
? `${ postType }-${ editedEntity.slug }`
: `single-${ postType }-${ editedEntity.slug }`;
} else {
slugToCheck = postType === 'page' ? 'page' : `single-${ postType }`;
}
return select( STORE_NAME ).getDefaultTemplateId( {
slug: slugToCheck,
} );

@Mamaduka
Copy link
Member

Started a draft PR - #69516.

@Mamaduka Mamaduka moved this from 📥 Todo to 🏗️ In Progress in WordPress 6.8 Editor Tasks Mar 11, 2025
@github-project-automation github-project-automation bot moved this from 🏗️ In Progress to ✅ Done in WordPress 6.8 Editor Tasks Mar 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Package] Editor /packages/editor [Type] Bug An existing feature does not function as intended
Projects
Development

Successfully merging a pull request may close this issue.

2 participants