Skip to content
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

backspace does not work on first keystroke for new single character text block #128

Open
plaisted opened this issue Jun 23, 2024 · 6 comments

Comments

@plaisted
Copy link

This is using the latest react-editor-view branch. Sounds sort of similar some of the issues in #42

When a new paragraph or heading is added with a single character, backspace does not work. To remove the character backspace must be hit twice. Note this does not seem to be isolated to backspace, as shift left also fails to highlight the character.

  • I am also using the baseKeyMap (for backspace) but I've validated none of the commands are used so this goes to the normal keystroke handling for the content editable.
  • The first backspace does create a transaction but there are no steps associated with it
  • Prosemirror document state is identical for both backspaces (one that works and one that doesn't).
  • If I load the same state fresh in a new prosemirror instance backspace works fine, this only occurs in the editor when the single character node is created
  • If I add more characters (or paragraphs after it) every works as expected
prosemirror.mp4
@smoores-dev
Copy link
Collaborator

Thanks for the report @plaisted! Can you confirm which version you're using? We recently changed the deletion behavior in the react-editor-view branch; I'm trying to figure out whether we broke this recently or may have just fixed it

@plaisted
Copy link
Author

Hi @smoores-dev , I'm using 0.7.0-next.5 which is the latest published version.

@smoores-dev
Copy link
Collaborator

@plaisted would you be able to either share your schema and node views, or create a minimal reproduction in codepen or some such? I'm actually unable to reproduce locally!

@plaisted
Copy link
Author

I saved a branch with the issue but will take some with to extract everything into something shareable.

@smoores-dev
Copy link
Collaborator

Thanks, I appreciate it!

@smoores-dev
Copy link
Collaborator

Howdy! I’ve had a chance to look into this a bit more, and here’s what I’ve learned:

  • This isn't a "real" bug; it's only in Strict mode, in a development build. This won't be a problem in production (unless you’re using Concurrent Mode features)
  • The reason that Strict mode does what it does is to prepare developers for React Concurrent mode. This issue with Strict mode does mean that react-prosemirror may experience subtle issues (potentially just this relatively minor one, but potentially others as well) in Concurrent mode. This is fine; I don’t know that concurrent mode makes a lot of sense for rich text editors anyway (it's better for situations where user input in one component can cause significant rerenders in another, like filtering search results). But I am planning on taking a look at whether it's possible to resolve this issue anyway.

Just wanted to make sure it was clear that this isn't blocking and won't be a problem for users in production!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants