-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
core: add OutlineTextNode splitText with selection tests #121
Conversation
focusOffset: 2, | ||
}, | ||
], | ||
[ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test is failing and I'd like to clarify the correct behavior before proceeding further - When a text is split into 3 chunks, should the start and end of the selection fall on the first and the third chunk respectively?
For example, intuitively, when a selection is split like this, the anchor and focus should be on the first and third node respectively?
"Hello World" -> "Hell" "o " "World"
^^^^^^ ^^ ^^ ^^
The current behavior is that the focus is on the second node with an offset of 4. Not sure if intended or a bug.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is definitely a bug! Nice one catching it. I suspected that this logic might have been a bit fragile and this text confirms it :)
This makes sense as to why I was running into issues with some of the www plugins and had to manually select the node after, which seemed it a bit strange.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great, I'll follow up and fix it in this PR!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ready for review!
@@ -119,14 +119,13 @@ function splitText( | |||
const sibling = getWritableNode(createTextNode(part)); | |||
sibling.__flags = flags; | |||
const siblingKey = sibling.__key; | |||
const nextTextSize = textLength + partSize; | |||
const nextTextSize = textSize + partSize; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the bug is here.
|
||
if (selection !== null) { | ||
const anchorOffset = selection.anchorOffset; | ||
const focusOffset = selection.focusOffset; | ||
|
||
if ( | ||
selection !== null && |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Safe to remove since L124 checks this
* core: add OutlineTextNode splitText with selection tests * core: fix core
Summary
Follow up of #118, where we add
splitText()
with current selections.Test Plan
Tests added.