-
Notifications
You must be signed in to change notification settings - Fork 3.3k
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
Fix for duplicating void nodes on split. #2907
Fix for duplicating void nodes on split. #2907
Conversation
I think this is something that should be fixed at a higher level. And |
@ianstormtaylor do you mean this should be accounted for only in Also, is the intended behavior for splitting void nodes to duplicate the node as happens currently or is there some other behavior that would be desirable? For non-void nodes it splits the children of the node at the position given. Void nodes have no children by definition so that behavior already seems inconsistent. I'm happy to do the work to make the change if you have thoughts on the above. 👍 |
@outreach-soren yup, handled in I think this might be solved in #2809, or at least made easier to solve. I'd hold off until I can get that one merged I think, because it touches so much of this code. |
…oid nodes removed from splitNodeByPath
@ianstormtaylor I was also thinking that but I was getting hung up on how to determine whether the range should be moved before or after the void. Idk how that'd be determined currently. Maybe it should just always be before? I think it's reasonable to punt that decision for another PR though. I've updated this pr to not make changes to |
Hey @ianstormtaylor are you still wanting to hold off on this til #2809 is merged or do you feel ok accepting it now that the scope of the changes is restricted to |
lindacalmmothtierealisingthatshewill-leaveyouguystoit.ihavenodesktopjustmobile:iwillseetheapp.alwayshappytohelp:byebye |
@ianstormtaylor doesn't seem like there's been any movement on that PR you linked initially. Can we move ahead with this in the mean-time? This is kind of a high impact bug for the end user and I don't really want to have to manually re-implement all of |
Fixed by #3093. |
Is this adding or improving a feature or fixing a bug?
This is fixing a bug where void nodes were being duplicated when
splitDescendantsByPath
was called with thetextPath
for a void node instead of a text node. I noticed this occurring specifically when callingwrapInlineAtRange
with the start of the selection inside a void node.What's the new behavior?
The new behavior is that void nodes are not split at the beginning of
wrapInlineAtRange
and the result to the end user is that void nodes are not duplicated if the start or end of the range is inside a void node when callingeditor.wrapInline
.I hope the use-cases this change accounts for should be pretty clear based on the tests added but just to give a more tangible example of how this manifests -
Calling
editor.wrapInline
when the anchor or focus point is "in" a void node.before -
https://cl.ly/18e5ce937c29
after -
https://cl.ly/cf78d60e501b
How does this change work?
This change consists of 3 logical changes.
wrapInlineAtRange
if they are void.startChild
as thestartInner
if it's void since it won't be split.previousSibling
for theendInner
ifendChild
is void since it won't be split.This solves the behavior that was causing me problems, and I feel like it's a plausible solution to this issue so I figured I'd put it up in a PR to get feedback instead of just opening an issue. My main remaining question though is whether the anchor or focus point should be allowed to be inside a void node at all... If so then I think this is a good solution as my understanding is that void nodes are essentially indivisible blocks with no inner content to actually split, almost like a character in a text node. Hypothetically though if we did want void nodes to be splittable but didn't want to allow the anchor or focus to be inside them, then enforcing that standard to prevent this issue from occurring in
wrapInlineAtRange
in the first place could be another solution.There may also be some other solution I'm not thinking of. The current behavior is obviously not desired though.
Have you checked that...?
yarn test
.yarn lint
. (Fix errors withyarn prettier
.)yarn watch
.)Does this fix any issues or need any specific reviewers?
🤷♂
Fixes: #
Reviewers: @