Skip to content
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
4 changes: 4 additions & 0 deletions packages/rich-text/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## Unreleased

### Bug Fixes

- Remove the format boundary highlight from a field when the selection moves to another field ([#86168](https://github.com/WordPress/gutenberg/pull/86168)).

## 8.0.0 (2026-10-20)

### Breaking Changes
Expand Down
7 changes: 7 additions & 0 deletions packages/rich-text/src/hook/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,13 @@ function useRichTextBase( {
hasFocus( ref.current! )
) {
applyRecord( recordRef.current! );
} else if (
recordRef.current!.start === undefined &&
ref.current!.querySelector( '[data-rich-text-format-boundary]' )
) {
// The editing host may be an ancestor that keeps focus, so the
// boundary would remain visible.
applyRecord( recordRef.current! );
}
}, [ selectionStart, selectionEnd, isSelected ] );

Expand Down
30 changes: 30 additions & 0 deletions test/e2e/specs/editor/various/rich-text.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,36 @@
);
} );

test( 'should not highlight the format of a deselected block', async ( {

Check notice on line 157 in test/e2e/specs/editor/various/rich-text.spec.js

View workflow job for this annotation

GitHub Actions / Run new e2e tests on trunk

This test fails on trunk, a good sign that it catches the bug.
page,
editor,
} ) => {
await editor.insertBlock( {
name: 'core/heading',
attributes: { content: '<strong>Heading text</strong> end' },
} );
await editor.insertBlock( {
name: 'core/paragraph',
attributes: { content: 'a <em>italic</em> b' },
} );
const italic = editor.canvas.locator( 'em' );
await italic.click();
await expect( italic ).not.toHaveCSS(
'background-color',
'rgba(0, 0, 0, 0)'
);

await page.keyboard.press( 'ArrowUp' );

await expect(
editor.canvas.getByRole( 'document', { name: 'Block: Heading' } )
).toHaveClass( /is-selected/ );
await expect( italic ).toHaveCSS(
'background-color',
'rgba(0, 0, 0, 0)'
);
} );

test( 'should return focus when pressing formatting button (-firefox)', async ( {
page,
editor,
Expand Down
Loading