From c0cef4a211da4c0a618d5f3e1b7d1504ee05743c Mon Sep 17 00:00:00 2001 From: Kevin Ansfield Date: Tue, 10 Apr 2018 11:26:22 +0100 Subject: [PATCH] Koenig - Fixed UP or LEFT on a blank list item jumping cursor to title refs https://github.com/TryGhost/Ghost/issues/9505 - ListItem sections have a parent rather than a prev section so we need to look for a section before the parent section when determining if the cursor is at the beginning of the doc for Up and Left key handling --- lib/koenig-editor/addon/components/koenig-editor.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/koenig-editor/addon/components/koenig-editor.js b/lib/koenig-editor/addon/components/koenig-editor.js index e34c08af2b..8fb59c5d00 100644 --- a/lib/koenig-editor/addon/components/koenig-editor.js +++ b/lib/koenig-editor/addon/components/koenig-editor.js @@ -595,8 +595,9 @@ export default Component.extend({ // the doc handleUpKey(editor) { let {isCollapsed, head: {offset, section}} = editor.range; + let prevSection = section.isListItem ? section.parent.prev : section.prev; - if (isCollapsed && !section.prev && offset === 0) { + if (isCollapsed && offset === 0 && !prevSection) { this.cursorDidExitAtTop(); } @@ -608,7 +609,8 @@ export default Component.extend({ // trigger a closure action to indicate that the caret "left" the top of // the editor canvas if the caret is at the very beginning of the doc - if (isCollapsed && !section.prev && offset === 0) { + let prevSection = section.isListItem ? section.parent.prev : section.prev; + if (isCollapsed && offset === 0 && !prevSection) { this.cursorDidExitAtTop(); return; }