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
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,9 @@ export default ( props ) => ( element ) => {
// snapshot must not skip synchronization.
selectionSnapshot = undefined;
} else {
applyRecord( record.current, { domOnly: true } );
// The document's selection may have moved elsewhere while the
// element was blurred, so restore it from the record.
applyRecord( record.current );
}

onSelectionChange( record.current.start, record.current.end );
Expand Down
10 changes: 8 additions & 2 deletions test/e2e/specs/editor/various/block-notes.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -1723,13 +1723,19 @@ test.describe( 'Block Notes', () => {

/*
* Pressing Escape closes the link popover and leaves the note
* form intact — focus does not get yanked out of the editor.
* form intact; focus does not get yanked out of the editor, and
* the selection is restored rather than left collapsed.
*/
await page.keyboard.press( 'Escape' );
await expect(
page.getByRole( 'combobox', { name: 'Search or type URL' } )
).toBeHidden();
await expect( textbox ).toBeVisible();
await expect( textbox ).toBeFocused();
await expect
.poll( () =>
page.evaluate( () => window.getSelection().toString() )
)
.toBe( 'visit example' );
} );

test( 'Cmd+K opens an unclipped link popover in the reply form', async ( {
Expand Down
Loading