Skip to content
This repository has been archived by the owner on Nov 28, 2022. It is now read-only.

Commit

Permalink
Koenig - Fixed UP or LEFT on a blank list item jumping cursor to title
Browse files Browse the repository at this point in the history
refs TryGhost/Ghost#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 <kbd>Up</kbd> and <kbd>Left</kbd> key handling
  • Loading branch information
kevinansfield committed Apr 10, 2018
1 parent 426e5a8 commit c0cef4a
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lib/koenig-editor/addon/components/koenig-editor.js
Expand Up @@ -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();
}

Expand All @@ -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;
}
Expand Down

0 comments on commit c0cef4a

Please sign in to comment.