Skip to content

Commit

Permalink
Merge pull request #14659 from ckeditor/ck/13411
Browse files Browse the repository at this point in the history
Fix (typing): The editor should scroll to the selection after inserting the text. Closes #13411.
  • Loading branch information
niegowski authored Jul 26, 2023
2 parents 22db2cf + 1f4a28d commit 4b4253e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
2 changes: 2 additions & 0 deletions packages/ckeditor5-typing/src/input.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,8 @@ export default class Input extends Plugin {
}

editor.execute( 'insertText', insertTextCommandData );

view.scrollToTheSelection();
} );

if ( env.isAndroid ) {
Expand Down
13 changes: 13 additions & 0 deletions packages/ckeditor5-typing/tests/input.js
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,19 @@ describe( 'Input', () => {

sinon.assert.notCalled( spy );
} );

it( 'should scroll to the selection after inserting text', async () => {
const scrollToSelectionSpy = sinon.spy( editor.editing.view, 'scrollToTheSelection' );

viewDocument.fire( 'insertText', {
text: 'bar',
selection: viewDocument.selection,
preventDefault: () => {}
} );

sinon.assert.calledOnce( insertTextCommandSpy );
sinon.assert.calledOnce( scrollToSelectionSpy );
} );
} );
} );

Expand Down

0 comments on commit 4b4253e

Please sign in to comment.