Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MoveNodeByPath broken? #2328

Closed
skogsmaskin opened this issue Oct 26, 2018 · 6 comments
Closed

MoveNodeByPath broken? #2328

skogsmaskin opened this issue Oct 26, 2018 · 6 comments

Comments

@skogsmaskin
Copy link
Collaborator

skogsmaskin commented Oct 26, 2018

Do you want to request a feature or report a bug?

I was trying to add some tests for the by-path commands, and tried adding a simple test for just switching positions of two blocks. I can't get it to work, it will just replace one of the blocks.

I.e. change.moveNodeByPath([0], [1], 1)

What's the current behavior?

It will replace one of the blocks leaving only one of the two blocks behind.

Relevant fiddle: https://jsfiddle.net/skogsmaskin/t54xc1ap/1/

What's the expected behavior?

As I understand moveNodeByPath it should not replace blocks, but just move it? I want to move the first block below the second one.

Could be I misunderstand something here, some input would be appriciated.

@ianstormtaylor
Copy link
Owner

@skogsmaskin might it have something to do with the inconsistent behavior mentioned in #2192?

@skogsmaskin
Copy link
Collaborator Author

@ianstormtaylor Yeah, that's probably part of the problem (the path annotation for the newPath param is very confusing). But I consider it a bug that it will actually delete/replace nodes like in the above fiddle? It should maybe throw an error instead until moveNodeByPath is refactored like you propose in #2192.

@jtadmor
Copy link
Contributor

jtadmor commented Jan 22, 2019

@skogsmaskin @ianstormtaylor I believe that the particular fiddle was not showing an actual break in moveNodeByPath.

I was able to get the operation to work as expected by changing the code to call the underlying applyOperation directly: https://jsfiddle.net/La0bsjm1/3/

I think the reason we were seeing that behavior was because of the CorePlugin rule preventing mixing block and text nodes:

// Only allow block nodes or inline and text nodes in blocks.

The jsfiddle is actually moving a paragraph node to be the child of a paragraph that already has an existing text child node, so (I think) the new node was just being removed right after the move_node operation went through.

(See tests in #2555)

@ianstormtaylor
Copy link
Owner

Is this fixed now?

@nz-chris
Copy link

Doesn't seem to be fixed. I ended up using editor.applyOperation with type as move_node instead.

@ianstormtaylor ianstormtaylor mentioned this issue Nov 6, 2019
@ianstormtaylor
Copy link
Owner

As of #3093 (which was just merged), I believe this issue is no longer applicable, because a lot has changed. I'm going through and closing out any potential issues that are not out of date with the overhaul. Thanks for understanding.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants