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

Rich Text: Only apply focus to elements not selection #58745

Merged
merged 4 commits into from
Feb 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand Down
42 changes: 42 additions & 0 deletions test/e2e/specs/editor/blocks/links.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: `<a href="https://wordpressfoundation.org/donate/">Donate to the WordPress Foundation</a> to support <a href="https://wordpress.org/gutenberg">Gutenberg</a>`,
},
} );

// 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: 100 } );

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,
Expand Down
Loading