Skip to content

Conversation

@draphy
Copy link

@draphy draphy commented Jan 15, 2026

Issues

Fixes #2494
Fixes #2470

Description

Applying suggestions in Draft.js (X/Twitter) and Slate (Discord) editors broke keyboard input.

Fix: Use surgical text replacement with execCommand that editors can observe and sync their internal state.

How Has This Been Tested?

  • Manually tested on X/Twitter and Discord web
  • Added integration tests for Draft.js and Slate verifying arrow keys and backspace work after applying suggestions

Checklist

  • I have performed a self-review of my own code
  • I have added tests to cover my changes

@draphy draphy changed the title fix(chrome-ext): Applying suggestions breaks cursor/keyboard in X/Twitter fix(chrome-ext): Applying suggestions breaks cursor/keyboard in Draft.js editors Jan 16, 2026
@elijah-potter
Copy link
Collaborator

This looks great! I'm tempted to just hit merge now.

Before I can do that, I would like to know: Did you end up having a go at writing an integration test to make sure it now works as expected on Draft.js? If not, that's totally fine, but I would like to know if you encountered any snags.

I'm curious if this PR has the potential to address #2470.

@draphy
Copy link
Author

draphy commented Jan 16, 2026

This looks great! I'm tempted to just hit merge now.

Before I can do that, I would like to know: Did you end up having a go at writing an integration test to make sure it now works as expected on Draft.js? If not, that's totally fine, but I would like to know if you encountered any snags.

I'm curious if this PR has the potential to address #2470.

Was planning to add integration tests. Checked the existing ones and some use local mocks, others use live sites (Slate, Lexical). Was initially hesitant about depending on an external live page, but setting up a local Draft.js mock with React felt overly complex. Since you mentioned test, i reconsidered it and going with https://draftjs.org/ seems simpler and consistent with the other editor tests. Tested manually as of now and it works fine. Will push the tests shortly. Let me know if you have any suggestions.

For #2470 - symptoms look identical. I'll check what editor Discord uses and if it's not already fixed by this PR, I'll include the fix here.

@draphy draphy changed the title fix(chrome-ext): Applying suggestions breaks cursor/keyboard in Draft.js editors fix(chrome-ext): Applying suggestions breaks cursor/keyboard in Draft.js and Slate editors Jan 16, 2026
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

Successfully merging this pull request may close these issues.

Applying suggestions in Draft.js editors breaks cursor and keyboard input Text input breaks after accepting Harper suggestion in Discord on Brave

2 participants