From 0404b5584ef3d8436b1b323104607f598461fe70 Mon Sep 17 00:00:00 2001 From: Hiroshi Urabe Date: Thu, 22 Jul 2021 17:23:08 +0900 Subject: [PATCH] If select-all fires in .editor-post-title__input, end the process.. (#33621) --- .../components/writing-flow/use-select-all.js | 6 ++++++ .../editor/various/multi-block-selection.test.js | 16 ++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/packages/block-editor/src/components/writing-flow/use-select-all.js b/packages/block-editor/src/components/writing-flow/use-select-all.js index 0ce2deb1ec4be4..8ddd9efaf19530 100644 --- a/packages/block-editor/src/components/writing-flow/use-select-all.js +++ b/packages/block-editor/src/components/writing-flow/use-select-all.js @@ -31,6 +31,12 @@ export default function useSelectAll() { return; } + if ( + event.target.classList.contains( 'editor-post-title__input' ) + ) { + return; + } + const selectedClientIds = getSelectedBlockClientIds(); if ( diff --git a/packages/e2e-tests/specs/editor/various/multi-block-selection.test.js b/packages/e2e-tests/specs/editor/various/multi-block-selection.test.js index 00c1d221e6d91e..4465ca162ad7c9 100644 --- a/packages/e2e-tests/specs/editor/various/multi-block-selection.test.js +++ b/packages/e2e-tests/specs/editor/various/multi-block-selection.test.js @@ -655,4 +655,20 @@ describe( 'Multi-block selection', () => { // Expect both paragraphs to be deleted. expect( await getEditedPostContent() ).toMatchSnapshot(); } ); + + it( 'should select title if the cursor is on title', async () => { + await clickBlockAppender(); + + await page.keyboard.type( '1' ); + await page.keyboard.press( 'Enter' ); + await page.keyboard.type( '2' ); + + await page.type( '.editor-post-title__input', 'Post title' ); + + await pressKeyWithModifier( 'primary', 'a' ); + const selectedText = await page.evaluate( () => { + return window.getSelection().toString(); + } ); + expect( selectedText ).toEqual( 'Post title' ); + } ); } );