Skip to content

Fix delete forward list for items with multiple children#2597

Merged
12joan merged 6 commits intoudecode:mainfrom
nicktrn:fix-delete-forward-list
Sep 11, 2023
Merged

Fix delete forward list for items with multiple children#2597
12joan merged 6 commits intoudecode:mainfrom
nicktrn:fix-delete-forward-list

Conversation

@nicktrn
Copy link
Copy Markdown
Contributor

@nicktrn nicktrn commented Sep 1, 2023

Description

Slate's deleteForward leaves behind an empty node when merging list items with multiple children, e.g. marked and unmarked text. To avoid duplicating otherwise sound delete logic, this fix calls deleteForward first and then deletes the empty node.

An alternative attempt included unwrapping LICs, letting vanilla deleteForward do its magic, and counting on normalization to fix things up. Sadly, edge cases were non-trivial to solve.

Tests

Added two tests, one for the issue at hand and one for sublists re #1152. However, the sublist test that should have failed passes just fine even before this fix. It's possible this has something to do with the editor config instead.

Fixes #2420
/claim #2420
/split @rishi-raj-jain

@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Sep 1, 2023

🦋 Changeset detected

Latest commit: 00e15fa

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 5 packages
Name Type
@udecode/plate-list Patch
@udecode/plate-indent-list Patch
@udecode/plate Patch
@udecode/plate-serializer-md Patch
@udecode/plate-serializer-docx Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@vercel
Copy link
Copy Markdown

vercel bot commented Sep 1, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
plate ✅ Ready (Inspect) Visit Preview 💬 Add feedback Sep 11, 2023 3:38pm

@reviewpad
Copy link
Copy Markdown
Contributor

reviewpad bot commented Sep 1, 2023

Thank you @nicktrn for this first contribution!

@reviewpad reviewpad bot added the medium Pull request is medium label Sep 1, 2023
@nicktrn nicktrn marked this pull request as ready for review September 1, 2023 22:02
@rishi-raj-jain
Copy link
Copy Markdown

Appreciate you putting in the PR and splitting it with me, @nicktrn 🤍

This is something that's adding value to Slate / Plate for a issue that hasn't been resolved for a year!

zbeyens
zbeyens previously approved these changes Sep 2, 2023
@12joan
Copy link
Copy Markdown
Collaborator

12joan commented Sep 2, 2023

Thanks for the PR. I've rewarded the bounty. Hopefully that got split between the two of you like Algora said it would; the rewarding UI wasn't very clear about that. (@rishi-raj-jain If it didn't send you anything, I can remedy that with the /tip command.)

Would it be possible to extend this fix to also cover #1152, a related issue that occurs when deleting backward?

recording.mp4

@nicktrn
Copy link
Copy Markdown
Contributor Author

nicktrn commented Sep 3, 2023

@12joan Sure thing, will finish this up as soon as I get a chance. Glad everything worked out with the split in the end!

@rishi-raj-jain No worries, I'm sure we both banged our head against the wall with this one.

@12joan
Copy link
Copy Markdown
Collaborator

12joan commented Sep 11, 2023

Thanks, @nicktrn! Let's see if this works...

/tip 50

@algora-pbc
Copy link
Copy Markdown

algora-pbc bot commented Sep 11, 2023

👉 @12joan: Click here to proceed

@algora-pbc
Copy link
Copy Markdown

algora-pbc bot commented Sep 11, 2023

🎉🎈 @nicktrn has been awarded $50! 🎈🎊

@12joan 12joan merged commit fd7ed42 into udecode:main Sep 11, 2023
@zbeyens zbeyens mentioned this pull request Sep 11, 2023
@nicktrn
Copy link
Copy Markdown
Contributor Author

nicktrn commented Sep 11, 2023

The two of you sure are fast. Glad both issues are now resolved. Thanks for the tip!

#1152 will have to be manually closed as I forgot to tag it as fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

medium Pull request is medium 💰 Rewarded

Projects

None yet

Development

Successfully merging this pull request may close these issues.

deleteForward swaps list items when subsequent list item contains mark

4 participants