Pressing keys around hashtag (#) makes cursor jump more than one character
See original GitHub issueDescription From slate 0.70.0, pressing keys around hashtag (#) makes cursor jump more than one character.
Recording
Sandbox https://codesandbox.io/s/slate-0-5x-forked-xdp6z
Steps To reproduce the behavior:
- Go to Sandbox from the link above
- Type
# # foobar
- Press arrow key around
#
- The cursor moves more than one character
Expectation
Cursor moves only one character around #
Environment
- Slate Version: 0.70.0
- Operating System: CodeSandbox and Ubuntu 20.04
- Browser: Chrome 95
Context
Having tested locally I found that I can observe this behavior from https://github.com/ianstormtaylor/slate/commit/5818aca5038f38465a5769fe944f184be0255341. #4565
Taking look at the code and running additional unit tests (packages/slate/test/utils/string.ts
) locally I found that getCharacterDistance
handles KeyCap improperly.
Below are the test cases I found failing.
const codepoints = [
...
[' #', 1],
['# ', 1],
...
]
I am not familiar with code point so I might be misunderstanding stuff. Thanks in advance.
Issue Analytics
- State:
- Created 2 years ago
- Comments:9 (3 by maintainers)
Top Results From Across the Web
Arrow keys jump more than one character - Super User
They jump to the end of the line instead of just one character. It's so frustraing, been searching around for days now, with...
Read more >Pressing arrow keys makes the cursor moves two spaces
For some reason, pressing the left or right arrow keys on my keyboard ( Logitech Canvas) makes the cursor moves not one, but...
Read more >Cursor jumps or moves randomly while typing in Windows 10
If you find that your mouse cursor jumps or moves on its own, automatically, randomly while typing in Windows laptop or computer, then...
Read more >cursor is jumping when pressing the arrow keys - Stack Overflow
cursor is jumping when pressing the arrow keys ; The way you are stopping them enter # is wrong. You should just check...
Read more >How to solve the case of the laptop's jumping cursor
Usually when the cursor jumps around without reason, it's caused by the user accidentally hitting the mouse touchpad.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@unageek I see! Anyways thank you for your great work 💯
@hitochan777 Thank you for your suggestion! I’ve just opened PR #4671 and added the additional tests.