From 603ccd64058af21f323bdbde8df836b68c2fd130 Mon Sep 17 00:00:00 2001 From: Tadeusz Piskozub Date: Mon, 16 Jan 2017 13:59:13 +0100 Subject: [PATCH 1/9] Test: add manual test. --- tests/tickets/14894/manual/1.html | 51 +++++++++++++++++++++++++++++++ tests/tickets/14894/manual/1.md | 17 +++++++++++ 2 files changed, 68 insertions(+) create mode 100755 tests/tickets/14894/manual/1.html create mode 100755 tests/tickets/14894/manual/1.md diff --git a/tests/tickets/14894/manual/1.html b/tests/tickets/14894/manual/1.html new file mode 100755 index 00000000000..534f131eb6e --- /dev/null +++ b/tests/tickets/14894/manual/1.html @@ -0,0 +1,51 @@ + +
+ + diff --git a/tests/tickets/14894/manual/1.md b/tests/tickets/14894/manual/1.md new file mode 100755 index 00000000000..ccad4e67453 --- /dev/null +++ b/tests/tickets/14894/manual/1.md @@ -0,0 +1,17 @@ +@bender-tags: 4.7.0, tc, 14894 +@bender-ui: collapsed +@bender-ckeditor-plugins: clipboard, contextmenu, toolbar, wysiwygarea, link + +## Test scenario + +For each editor: +1. Scroll it without focusing. +2. Open the link dialog. + +## Expected result + +Scroll position remains unchanged. + +## Unexpected + +Editor scroll position is moved to top. From e259d642d36df1218a764d627d51a78b2323a4d9 Mon Sep 17 00:00:00 2001 From: Tadeusz Piskozub Date: Mon, 16 Jan 2017 13:59:35 +0100 Subject: [PATCH 2/9] Save/restore scroll position on focus. --- core/editable.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/core/editable.js b/core/editable.js index c50ec7fe80e..da7f301a4f6 100644 --- a/core/editable.js +++ b/core/editable.js @@ -87,7 +87,11 @@ if ( CKEDITOR.env.ie && !( CKEDITOR.env.edge && CKEDITOR.env.version > 14 ) && this.getDocument().equals( CKEDITOR.document ) ) { this.$.setActive(); } else { + // We have no control over exactly what happens when the native `focus` method is called, + // so save the scroll position and restore it later. + var scrollPos = this.$.scrollTop; this.$.focus(); + this.$.scrollTop = scrollPos; } } catch ( e ) { // IE throws unspecified error when focusing editable after closing dialog opened on nested editable. From 8086b7b3e404985de71d45c4560007ecdeeb423b Mon Sep 17 00:00:00 2001 From: Tadeusz Piskozub Date: Fri, 3 Feb 2017 17:55:42 +0100 Subject: [PATCH 3/9] Tests: add unit test. --- tests/core/editable/misc.js | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/tests/core/editable/misc.js b/tests/core/editable/misc.js index 0b31a77e0bf..90e6c1defb1 100644 --- a/tests/core/editable/misc.js +++ b/tests/core/editable/misc.js @@ -9,6 +9,13 @@ bender.editors = { config: { allowedContent: true } + }, + scrollable: { + name: 'editor2', + creator: 'replace', + config: { + height: 300 + } } }; @@ -96,5 +103,23 @@ bender.test( { assert.areSame( 'foo', editor.getSelection().getSelectedText(), 'Selection has not been changed' ); } ); + }, + + 'test scroll editable and focus': function() { + var bot = this.editorBots.scrollable, + editable = this.editors.scrollable.editable(); + + bot.setData( '

Test

Test

Test

Test

' + + '

Test

Test

Test

Test

' + + '

Test

Test

Test

Test

' + + '

Test

Test

Test

Test

' + + '

Test

Test

Test

Test

', function() { + var scrollPos = 100; + + editable.$.scrollTop = scrollPos; + editable.focus(); + + assert.areSame( scrollPos, editable.$.scrollTop ); + } ); } -} ); \ No newline at end of file +} ); From 3016f2a74b18654e2a41d65fbcfa2e506c605732 Mon Sep 17 00:00:00 2001 From: Tadeusz Piskozub Date: Fri, 3 Feb 2017 17:58:30 +0100 Subject: [PATCH 4/9] Tests: run test only in chrome. --- tests/core/editable/misc.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/core/editable/misc.js b/tests/core/editable/misc.js index 90e6c1defb1..43d16c5c23b 100644 --- a/tests/core/editable/misc.js +++ b/tests/core/editable/misc.js @@ -106,6 +106,10 @@ bender.test( { }, 'test scroll editable and focus': function() { + if ( !CKEDITOR.env.webkit ) { + assert.ignore(); + } + var bot = this.editorBots.scrollable, editable = this.editors.scrollable.editable(); From 73e7b7afd7157552bd754bed6a39ee317dd2d618 Mon Sep 17 00:00:00 2001 From: Tadeusz Piskozub Date: Fri, 3 Feb 2017 18:00:09 +0100 Subject: [PATCH 5/9] Correct scrolling only in Chrome. --- core/editable.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/core/editable.js b/core/editable.js index da7f301a4f6..9bae3c2e529 100644 --- a/core/editable.js +++ b/core/editable.js @@ -89,9 +89,13 @@ } else { // We have no control over exactly what happens when the native `focus` method is called, // so save the scroll position and restore it later. - var scrollPos = this.$.scrollTop; - this.$.focus(); - this.$.scrollTop = scrollPos; + if ( CKEDITOR.env.webkit ) { + var scrollPos = this.$.scrollTop; + this.$.focus(); + this.$.scrollTop = scrollPos; + } else { + this.$.focus(); + } } } catch ( e ) { // IE throws unspecified error when focusing editable after closing dialog opened on nested editable. From f9e88d9f44e454d9a33ad6d8e15a87bc64f543e5 Mon Sep 17 00:00:00 2001 From: Tomasz Jakut Date: Tue, 7 Feb 2017 13:44:16 +0100 Subject: [PATCH 6/9] Restrict fix only for Chrome. --- core/editable.js | 2 +- tests/core/editable/misc.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/core/editable.js b/core/editable.js index 9bae3c2e529..d9b687248a5 100644 --- a/core/editable.js +++ b/core/editable.js @@ -89,7 +89,7 @@ } else { // We have no control over exactly what happens when the native `focus` method is called, // so save the scroll position and restore it later. - if ( CKEDITOR.env.webkit ) { + if ( CKEDITOR.env.chrome ) { var scrollPos = this.$.scrollTop; this.$.focus(); this.$.scrollTop = scrollPos; diff --git a/tests/core/editable/misc.js b/tests/core/editable/misc.js index 43d16c5c23b..0e778d8d03a 100644 --- a/tests/core/editable/misc.js +++ b/tests/core/editable/misc.js @@ -106,7 +106,7 @@ bender.test( { }, 'test scroll editable and focus': function() { - if ( !CKEDITOR.env.webkit ) { + if ( !CKEDITOR.env.chrome ) { assert.ignore(); } From 9cbd5351c80ada2f5b5d781f47d3a03b8396fd3d Mon Sep 17 00:00:00 2001 From: Tomasz Jakut Date: Tue, 7 Feb 2017 13:46:10 +0100 Subject: [PATCH 7/9] Moved manual test to editable tests. --- .../manual/1.html => core/editable/manual/scrollandfocus.html} | 0 .../14894/manual/1.md => core/editable/manual/scrollandfocus.md} | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename tests/{tickets/14894/manual/1.html => core/editable/manual/scrollandfocus.html} (100%) mode change 100755 => 100644 rename tests/{tickets/14894/manual/1.md => core/editable/manual/scrollandfocus.md} (100%) mode change 100755 => 100644 diff --git a/tests/tickets/14894/manual/1.html b/tests/core/editable/manual/scrollandfocus.html old mode 100755 new mode 100644 similarity index 100% rename from tests/tickets/14894/manual/1.html rename to tests/core/editable/manual/scrollandfocus.html diff --git a/tests/tickets/14894/manual/1.md b/tests/core/editable/manual/scrollandfocus.md old mode 100755 new mode 100644 similarity index 100% rename from tests/tickets/14894/manual/1.md rename to tests/core/editable/manual/scrollandfocus.md From 21ca60de9eaeb95b60ee544b893e7717b516d9ca Mon Sep 17 00:00:00 2001 From: Tomasz Jakut Date: Tue, 7 Feb 2017 14:03:43 +0100 Subject: [PATCH 8/9] Ignore manual test in no-Chrome. --- tests/core/editable/manual/scrollandfocus.html | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/core/editable/manual/scrollandfocus.html b/tests/core/editable/manual/scrollandfocus.html index 534f131eb6e..34caa785e36 100644 --- a/tests/core/editable/manual/scrollandfocus.html +++ b/tests/core/editable/manual/scrollandfocus.html @@ -46,6 +46,10 @@

Test

From 31773614d6208f0bd92ad2e71bcac8b98a336f52 Mon Sep 17 00:00:00 2001 From: Tomasz Jakut Date: Tue, 7 Feb 2017 14:20:16 +0100 Subject: [PATCH 9/9] Updated changelog. --- CHANGES.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGES.md b/CHANGES.md index d3d0e1e1235..7b7c6d73ab7 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -17,6 +17,7 @@ Fixed Issues: * [#11956](http://dev.ckeditor.com/ticket/11956): [Blink, IE] Fixed: [Link](http://ckeditor.com/addon/link) dialog does not open on a double click on the second word of the link with background color or other styles. * [#10472](http://dev.ckeditor.com/ticket/10472): Fixed: Unable to use [Table Resize](http://ckeditor.com/addon/tableresize) on table's header and footer. * [#16777](https://dev.ckeditor.com/ticket/16777): [Edge] Fixed: [Clipboard](http://ckeditor.com/addon/clipboard) plugin doesn't allow to drop widgets into editor. +* [#14894](https://dev.ckeditor.com/ticket/14894): [Chrome] Fixed: Editor scrolls to top after focusing or when a dialog is opened. ## CKEditor 4.6.2