Skip to content
New issue

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

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

Already on GitHub? # to your account

Undoing content inserted within a paragraph results in an error caused by a bad position path during the undo transformation #17267

Closed
aStewartDesign opened this issue Oct 15, 2024 · 3 comments · Fixed by #17427 · May be fixed by #17454
Assignees
Labels
package:engine resolution:resolved This issue was already resolved (e.g. by another ticket). squad:collaboration Issue to be handled by the Collaboration team. type:bug This issue reports a buggy (incorrect) behavior.

Comments

@aStewartDesign
Copy link
Contributor

📝 Provide detailed reproduction steps (if any)

  1. Use model.change(() => model.insertContent(...)) to insert two document fragments in the middle of a paragraph
  2. Execute the undo command twice
  3. On the second undo command, an error is thrown: CKEditorError: model-position-path-incorrect-format {"path":[]}

See my test case here which throws this error.

✔️ Expected result

No error is thrown and both changes are undone successfully.

❌ Actual result

An error is thrown: CKEditorError: model-position-path-incorrect-format {"path":[]}

❓ Possible solution

In my debugging, it seems like a bad path is getting created during the undo operation transformation. Even though the editor model only has one paragraph in it, an operation position is getting transformed into a position with the path [26]. I traced the bad path back to this transformation function which calls Position._getTransformedByMove, with the bad path ultimately getting created in Position._getCombined. After playing around with this a bit, I'm not exactly sure how to fix this so the positions get transformed correctly however this seems to be the location where the bad path is originally coming from.

📃 Other details

  • Browser: Chrome v130
  • OS: MacOS
  • First affected CKEditor version: unknown
  • Installed CKEditor plugins: ckeditor5-undo

If you'd like to see this fixed sooner, add a 👍 reaction to this post.

@scofalik
Copy link
Contributor

scofalik commented Nov 7, 2024

@aStewartDesign, thank you for bringing this to our attention and attaching steps to reproduce as a test case, this was very helpful.

Just letting you know that we have a PR with a fix for this bug: #17427

@scofalik scofalik added package:engine squad:collaboration Issue to be handled by the Collaboration team. labels Nov 7, 2024
@aStewartDesign
Copy link
Contributor Author

Thank you, much appreciated! 🙏🏻

oleq added a commit that referenced this issue Nov 13, 2024
Fix (engine): Fixed an editor crash after pasting over previously pasted content and undoing both actions. Closes #17267.
@CKEditorBot CKEditorBot added this to the iteration 80 milestone Nov 13, 2024
@oleq oleq reopened this Nov 13, 2024
@scofalik
Copy link
Contributor

Closed by #17427.

@DawidKossowski DawidKossowski added the resolution:resolved This issue was already resolved (e.g. by another ticket). label Jan 23, 2025
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
package:engine resolution:resolved This issue was already resolved (e.g. by another ticket). squad:collaboration Issue to be handled by the Collaboration team. type:bug This issue reports a buggy (incorrect) behavior.
Projects
None yet
5 participants