fix: Backspaces do not work when the code block contains initial data.#2836
Open
yosipy wants to merge 8 commits intocodex-team:nextfrom
Open
fix: Backspaces do not work when the code block contains initial data.#2836yosipy wants to merge 8 commits intocodex-team:nextfrom
yosipy wants to merge 8 commits intocodex-team:nextfrom
Conversation
neSpecc
reviewed
Oct 5, 2024
src/components/utils/caret.ts
Outdated
| */ | ||
| export function isCaretAtStartOfInput(input: HTMLElement): boolean { | ||
| const firstNode = $.getDeepestNode(input); | ||
| const firstNode = $.isNativeInput(input) ? input : $.getDeepestNode(input); |
Member
There was a problem hiding this comment.
I'd suggest to update getDeepestNode instead. It already contains a logic that will return a passed node, but seems like node[child] statement does not cover this case
Author
There was a problem hiding this comment.
Thank you for pointing it out.
I think you are right too.
Fixed in 8cec5c9.
neSpecc
reviewed
Oct 9, 2024
Member
neSpecc
left a comment
There was a problem hiding this comment.
seems ok, please add a line to the changelog
Author
|
Yes, I added it. |
This reverts commit 316514e.
|
When will this pull request be reviewed? It's a pretty annoying bug. |
Member
|
Hey, @yosipy would you please, add a test for this case? |
Author
|
I've been busy lately and don't have time to fix the code. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
fix: editor-js/code#75
editor-js/code#67
When we add a new code block, backspace works.
1.mp4
However, when updating a code block with initial data, backspaces do not work.
2.mp4
Cause
The value of the argument
inputof functionisCaretAtStartOfInput (src/components/utils/caret.ts)is as follows when there is no initial value.When there is an initial value, the value is as follows.
firstNodeis the string'console.log(“ssss”)'andisCaretAtStartOfInput()==true.Solution
When the argument
inputis native input,firstNodeis assignedinput.