From 680980aa7460ad716ac5f9b5c40e9bf2dc1d3b1c Mon Sep 17 00:00:00 2001 From: Aleksander Nowodzinski Date: Tue, 1 Aug 2017 15:22:04 +0200 Subject: [PATCH 1/2] Scroll the editing document to the selection after the DeleteCommand is executed. --- src/delete.js | 1 + tests/delete.js | 13 +++++++++++++ 2 files changed, 14 insertions(+) diff --git a/src/delete.js b/src/delete.js index 03fe599..1a0b25f 100644 --- a/src/delete.js +++ b/src/delete.js @@ -36,6 +36,7 @@ export default class Delete extends Plugin { this.listenTo( editingView, 'delete', ( evt, data ) => { editor.execute( data.direction == 'forward' ? 'forwardDelete' : 'delete', { unit: data.unit } ); data.preventDefault(); + editingView.scrollToTheSelection(); } ); } } diff --git a/tests/delete.js b/tests/delete.js index ae97305..76d1e94 100644 --- a/tests/delete.js +++ b/tests/delete.js @@ -51,6 +51,19 @@ describe( 'Delete feature', () => { expect( spy.calledWithMatch( 'delete', { unit: 'character' } ) ).to.be.true; } ); + it( 'scrolls the editing document to the selection after executing the command', () => { + const scrollSpy = sinon.stub( editingView, 'scrollToTheSelection', () => {} ); + const executeSpy = editor.execute = sinon.spy(); + + editingView.fire( 'delete', new DomEventData( editingView, getDomEvent(), { + direction: 'backward', + unit: 'character' + } ) ); + + sinon.assert.calledOnce( scrollSpy ); + sinon.assert.callOrder( executeSpy, scrollSpy ); + } ); + function getDomEvent() { return { preventDefault: sinon.spy() From f244a7b29598407d418160bf8f75bda2f40cb9d8 Mon Sep 17 00:00:00 2001 From: Aleksander Nowodzinski Date: Thu, 10 Aug 2017 10:58:27 +0200 Subject: [PATCH 2/2] Tests: Updated stubs to the latest Sinon API. --- tests/delete.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/delete.js b/tests/delete.js index 21e5493..b967b1a 100644 --- a/tests/delete.js +++ b/tests/delete.js @@ -53,7 +53,7 @@ describe( 'Delete feature', () => { } ); it( 'scrolls the editing document to the selection after executing the command', () => { - const scrollSpy = sinon.stub( editingView, 'scrollToTheSelection', () => {} ); + const scrollSpy = sinon.stub( editingView, 'scrollToTheSelection' ); const executeSpy = editor.execute = sinon.spy(); editingView.fire( 'delete', new DomEventData( editingView, getDomEvent(), {