-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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: Backspaces do not work when the code block contains initial data. #2836
base: next
Are you sure you want to change the base?
Conversation
src/components/utils/caret.ts
Outdated
@@ -112,7 +112,7 @@ export function checkContenteditableSliceForEmptiness(contenteditable: HTMLEleme | |||
* @param input - input where caret should be checked | |||
*/ | |||
export function isCaretAtStartOfInput(input: HTMLElement): boolean { | |||
const firstNode = $.getDeepestNode(input); | |||
const firstNode = $.isNativeInput(input) ? input : $.getDeepestNode(input); |
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'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
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.
Thank you for pointing it out.
I think you are right too.
Fixed in 8cec5c9.
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.
@neSpecc
Please re-review.
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.
seems ok, please add a line to the changelog
Yes, I added it. |
This reverts commit 316514e.
When will this pull request be reviewed? It's a pretty annoying bug. |
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
input
of 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.
firstNode
is the string'console.log(“ssss”)'
andisCaretAtStartOfInput()==true
.Solution
When the argument
input
is native input,firstNode
is assignedinput
.