From 0d63f20f5b1592d1d8c64a3ef8f87424b9d0e0af Mon Sep 17 00:00:00 2001 From: ntsekouras Date: Fri, 25 Sep 2026 11:26:49 +0300 Subject: [PATCH 1/2] Editor: Fix new posts being published with the `auto-draft` slug --- .../editor/src/components/post-url/index.jsx | 17 +++++++++---- .../editor/various/sidebar-permalink.spec.js | 25 +++++++++++++++++++ 2 files changed, 37 insertions(+), 5 deletions(-) diff --git a/packages/editor/src/components/post-url/index.jsx b/packages/editor/src/components/post-url/index.jsx index da5b16adef94cc..7881013f424bfe 100644 --- a/packages/editor/src/components/post-url/index.jsx +++ b/packages/editor/src/components/post-url/index.jsx @@ -34,6 +34,7 @@ export default function PostURL( { onClose } ) { const { isEditable, postSlug, + hasSlug, postLink, permalinkPrefix, permalinkSuffix, @@ -51,6 +52,7 @@ export default function PostURL( { onClose } ) { postSlug: safeDecodeURIComponent( select( editorStore ).getEditedPostSlug() ), + hasSlug: !! select( editorStore ).getEditedPostAttribute( 'slug' ), viewPostLabel: postType?.labels?.view_item, postLink: post.link, permalinkPrefix: permalinkParts?.prefix, @@ -141,11 +143,16 @@ export default function PostURL( { onClose } ) { } } } onBlur={ ( event ) => { - editPost( { - slug: cleanForSlug( - event.target.value - ), - } ); + // Without a slug the field shows a fallback, which for + // a new post is the `auto-draft` placeholder. Writing + // it would pin that value as the post slug. + if ( hasSlug ) { + editPost( { + slug: cleanForSlug( + event.target.value + ), + } ); + } if ( forceEmptyField ) { setForceEmptyField( false ); } diff --git a/test/e2e/specs/editor/various/sidebar-permalink.spec.js b/test/e2e/specs/editor/various/sidebar-permalink.spec.js index 700efcbe59b283..4998defd5f395f 100644 --- a/test/e2e/specs/editor/various/sidebar-permalink.spec.js +++ b/test/e2e/specs/editor/various/sidebar-permalink.spec.js @@ -10,6 +10,7 @@ test.describe( 'Sidebar Permalink', () => { } ); test.afterAll( async ( { requestUtils } ) => { + await requestUtils.deleteAllPosts(); await requestUtils.deactivatePlugin( 'gutenberg-test-custom-post-types' ); @@ -75,4 +76,28 @@ test.describe( 'Sidebar Permalink', () => { page.getByRole( 'button', { name: 'Change link' } ) ).toBeVisible(); } ); + + test( 'should not save the placeholder slug of a new post when the slug field loses focus', async ( { + admin, + editor, + page, + requestUtils, + } ) => { + await admin.createNewPost(); + await editor.openDocumentSettingsSidebar(); + await editor.canvas + .getByRole( 'textbox', { name: 'Add title' } ) + .fill( 'Hello Slug' ); + + await page.getByRole( 'button', { name: /^Change link/ } ).click(); + await page.getByRole( 'textbox', { name: 'Slug' } ).click(); + await page.keyboard.press( 'Tab' ); + await page.keyboard.press( 'Escape' ); + + const postId = await editor.publishPost(); + const post = await requestUtils.rest( { + path: `/wp/v2/posts/${ postId }`, + } ); + expect( post.slug ).toBe( 'hello-slug' ); + } ); } ); From 1c3bde045c8842508dc3b66a3aa88afba711f024 Mon Sep 17 00:00:00 2001 From: ntsekouras Date: Fri, 25 Sep 2026 11:43:24 +0300 Subject: [PATCH 2/2] changelog --- packages/editor/CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/editor/CHANGELOG.md b/packages/editor/CHANGELOG.md index 3d1ab06e02f619..e136dac46d9633 100644 --- a/packages/editor/CHANGELOG.md +++ b/packages/editor/CHANGELOG.md @@ -9,6 +9,7 @@ ### Bug Fixes - Error boundary: Explicitly announce the error title and description, excluding action labels ([#82737](https://github.com/WordPress/gutenberg/pull/82737)). +- `PostURL`: Leaving the slug field without typing no longer saves the displayed fallback as the slug, so a new post no longer publishes with the `auto-draft` slug ([#83518](https://github.com/WordPress/gutenberg/pull/83518)). ## 15.1.0 (2026-09-23)