From 0078724c21aff52e2366b5d0ebf227343c65f28e Mon Sep 17 00:00:00 2001 From: scruffian Date: Tue, 6 Feb 2024 17:49:43 +0000 Subject: [PATCH 1/4] Rich Text: Only apply focus to elements not selection --- packages/rich-text/src/component/use-input-and-selection.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/rich-text/src/component/use-input-and-selection.js b/packages/rich-text/src/component/use-input-and-selection.js index ecfcc2151a989..1b0cd03829469 100644 --- a/packages/rich-text/src/component/use-input-and-selection.js +++ b/packages/rich-text/src/component/use-input-and-selection.js @@ -241,7 +241,7 @@ export function useInputAndSelection( props ) { activeFormats: EMPTY_ACTIVE_FORMATS, }; } else { - applyRecord( record.current ); + applyRecord( record.current, { domOnly: true } ); } onSelectionChange( record.current.start, record.current.end ); From e0f425237bca25e1f918bf2a5cec17c4e37e4cbb Mon Sep 17 00:00:00 2001 From: Jerry Jones Date: Wed, 7 Feb 2024 10:37:46 -0600 Subject: [PATCH 2/4] Add regression test --- test/e2e/specs/editor/blocks/links.spec.js | 42 ++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/test/e2e/specs/editor/blocks/links.spec.js b/test/e2e/specs/editor/blocks/links.spec.js index 7ebdb33b10353..36ad8dd579b8a 100644 --- a/test/e2e/specs/editor/blocks/links.spec.js +++ b/test/e2e/specs/editor/blocks/links.spec.js @@ -878,6 +878,48 @@ test.describe( 'Links', () => { ] ); } ); + // Fix for https://github.com/WordPress/gutenberg/issues/58322 + test( 'can click links within the same paragraph to open the correct link preview (@firefox)', async ( { + editor, + LinkUtils, + } ) => { + // Create a paragraph with two links + await editor.insertBlock( { + name: 'core/paragraph', + attributes: { + content: `Donate to the Wordpress Foundation to support Gutenberg`, + }, + } ); + + // Click on "Gutenberg" link in the canvas + await editor.canvas + .getByRole( 'link', { + name: 'Gutenberg', + } ) + .click(); + + const linkPopover = LinkUtils.getLinkPopover(); + await expect( linkPopover ).toBeVisible(); + await expect( + linkPopover.getByText( 'wordpress.org/gutenberg' ) + ).toBeVisible(); + + // Click the other link in the same paragraph. We need a short delay between mousdown and mouseup to get the popover to show + await editor.canvas + .getByRole( 'link', { + name: 'WordPress', + } ) + .click( { delay: 10 } ); + + await expect( linkPopover ).toBeVisible(); + await expect( + linkPopover.getByText( 'wordpress.org/gutenberg' ) + ).toBeHidden(); + await expect( + linkPopover.getByText( 'wordpressfoundation.org/donate/' ) + ).toBeVisible(); + } ); + test.describe( 'Editing link text', () => { test( 'should allow for modification of link text via the Link UI', async ( { page, From 7d7ea09552702cf419398d1613ec49e4b8b25029 Mon Sep 17 00:00:00 2001 From: scruffian Date: Fri, 9 Feb 2024 11:03:47 +0000 Subject: [PATCH 3/4] increase the delay so the tests pass --- test/e2e/specs/editor/blocks/links.spec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/e2e/specs/editor/blocks/links.spec.js b/test/e2e/specs/editor/blocks/links.spec.js index 36ad8dd579b8a..2d1f63569d4c7 100644 --- a/test/e2e/specs/editor/blocks/links.spec.js +++ b/test/e2e/specs/editor/blocks/links.spec.js @@ -909,7 +909,7 @@ test.describe( 'Links', () => { .getByRole( 'link', { name: 'WordPress', } ) - .click( { delay: 10 } ); + .click( { delay: 100 } ); await expect( linkPopover ).toBeVisible(); await expect( From 437d4bf3ad7ded3372bc66e7a9c24c26dc9b1261 Mon Sep 17 00:00:00 2001 From: scruffian Date: Fri, 9 Feb 2024 11:04:28 +0000 Subject: [PATCH 4/4] Capital P dangit --- test/e2e/specs/editor/blocks/links.spec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/e2e/specs/editor/blocks/links.spec.js b/test/e2e/specs/editor/blocks/links.spec.js index 2d1f63569d4c7..0a95064032f83 100644 --- a/test/e2e/specs/editor/blocks/links.spec.js +++ b/test/e2e/specs/editor/blocks/links.spec.js @@ -887,7 +887,7 @@ test.describe( 'Links', () => { await editor.insertBlock( { name: 'core/paragraph', attributes: { - content: `Donate to the Wordpress Foundation to support Gutenberg`, + content: `Donate to the WordPress Foundation to support Gutenberg`, }, } );