- 
                Notifications
    
You must be signed in to change notification settings  - Fork 3.3k
 
Open
Labels
Description
Description
For moveNodes the to seems to be off when moving to a later sibling.  (Probably issue with move_node too.)
Steps
The given test passes, but it doesn't make sense.
/** @jsx jsx */
import { Transforms } from 'slate'
import { jsx } from '../../..'
export const input = (
  <editor>
    <block>1</block>
    <block>2</block>
    <block>3</block>
    <block>4</block>
  </editor>
)
const blockText = (n) => n.children && n.children[0].text || undefined
const match = (n, p) => ["1", "2"].includes(blockText(n))
export const run = editor => {
  Transforms.moveNodes(editor, { at: [], to: [2], match })
}
export const output = (
  <editor>
    <block>3</block>
    <block>1</block>
    <block>2</block>
    <block>4</block>
  </editor>
)Expectation
The path specified by to should presumably reference the position you want a node to be inserted at based on the slatejs node tree before the operation — so in this case nodes "1" and "2" should end up at path [2], which is right before "3".  In other words, this should be a no-op operation, but instead the nodes are inserted after "3".
If you move to an earlier sibling then it works as expected — if you try to move "4" to [2] it ends up before "3".
Am I misunderstanding something?
Environment
- Slate Version: 0.100