Skip to content

Commit

Permalink
fix selection when exiting table with arrow keys
Browse files Browse the repository at this point in the history
  • Loading branch information
deundrewilliams committed Mar 3, 2022
1 parent 02eb2ad commit 1c3192d
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions packages/obonode/obojobo-chunks-table/editor-registration.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,22 @@ const plugins = {

// Move editor selection based on direction given
const moveCursor = direction => {
const currentPath = editor.selection.anchor.path
const nextPath = calculateNextPath(direction)

if (nextPath !== editor.selection.anchor.path) {
const isExitingTable = nextPath[0] !== currentPath[0]

if (nextPath !== currentPath) {
const focus = Editor.start(editor, nextPath)
const anchor = Editor.end(editor, nextPath)
let anchor

// If exiting table, do not select entire content of new node
if (isExitingTable) {
anchor = focus
} else {
anchor = Editor.end(editor, nextPath)
}

Transforms.setSelection(editor, {
focus,
anchor
Expand Down

0 comments on commit 1c3192d

Please sign in to comment.