-
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 bugs when ctrl+backspace (mac) throws an error at the block start #1888
Conversation
@zhujinxuan I don't understand this one. What is ctrl-backspace supposed to do on Mac? If it's a Mac-specific change why is there not an environment check? Why also for delete? |
@ianstormtaylor Sorry I forgot to add gif; When I use the I did not do the environment check because perhaps something similar can happen in other platforms. if a |
I see what you mean. I think we should just be changing the behavior for I appreciate wanting to account for other platforms, but until we discover those I think it's better to keep it in the same system. |
@ianstormtaylor Great. I think it is much nicer to put it in slate-hotkeys rather than slate-react. I will fix that tomorrow. |
Fixed in the slate-hotkeys. To resolve all |
Reopen to generate deploy preview. |
isDeleteWordBackward, | ||
isDeleteWordForward, | ||
isDeleteCharForward, | ||
].find(fn => fn(e)) |
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 don't understand what's happening here, why is this needed? This method doesn't read like the others.
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.
Hi, this method means:
if a keyevent includes backspace or delete, and is not captured by other handlers. Then it will be captured by deleteCharBackward
. It ensures that all backspace/delete events are catched. Therefore, it will prevents issues like #1966 and #1983
Because when backspace events are not catched, the browser will catch the key and remove content without notifying the React.
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.
Okay... but why would that be inside a function called isDeleteCharBackward
then? It doesn't make sense. If anything, you'd make a new function called isDelete
and use that.
But further, there's already one called isContentEditable
that is used in the Before plugin that results in e.preventDefault()
being called. So it seems redundant?
So maybe there's some other reason?
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.
Oh, I see what you mean. I will fix it with isDelete
and isContentEditable
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.
Fixed~
Hi @ianstormtaylor . Anything else I shall do about this PR? |
packages/slate-hotkeys/src/index.js
Outdated
@@ -87,6 +106,7 @@ const isContentEditable = e => | |||
isDeleteLineForward(e) || | |||
isDeleteWordBackward(e) || | |||
isDeleteWordForward(e) || | |||
isOtherDelete(e) || |
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.
Instead of adding isOtherDelete
here, can we just re-use the existing isBackspace
or isDelete
from above? That seems like it would solve it in a way that's more clear and with less code.
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.
@ianstormtaylor Yes, we can. I put e.key ===
here. Fixed in a53e991
f623df4
to
bfbefc1
Compare
bfbefc1
to
9eb6b76
Compare
Codecov Report
@@ Coverage Diff @@
## master #1888 +/- ##
=========================================
- Coverage 67.06% 67% -0.07%
=========================================
Files 68 68
Lines 5660 5670 +10
=========================================
+ Hits 3796 3799 +3
- Misses 1864 1871 +7
Continue to review full report at Codecov.
|
9eb6b76
to
d6ab4dc
Compare
@zhujinxuan sorry for being unclear, I was trying to get at the fact that it was really a problem in the detection of the individual |
Is this adding or improving a feature or fixing a bug?
bugs;
How does this change work?
Because ctrl+backspace is un-handled by the
onKeyDown
; it will create crazyonInput
event, this PR aims to provides default behavior for un-handled backspace problems.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: #1887
Reviewers: @