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

Bug: Spellcheck triggers early because of custom insertText logic #186

Closed
zurfyx opened this issue Mar 18, 2021 · 1 comment · Fixed by #188
Closed

Bug: Spellcheck triggers early because of custom insertText logic #186

zurfyx opened this issue Mar 18, 2021 · 1 comment · Fixed by #188
Assignees

Comments

@zurfyx
Copy link
Member

zurfyx commented Mar 18, 2021

By default (Chrome) spellchecker waits for 1-2 seconds before triggering, so if you're typing hous you can still type house without the error underline showing. This works fine when native event handler triggers:

<div texteditable="true" spellcheck="true"></div>

Outline handles the events itself (OutlineEventHandlers):

event.preventDefault(); <--
...
      case 'insertText':
      case 'insertFromComposition': {
        if (data) {
          insertText(selection, data); <-- type it manually
        }
        break;
      }

Repro: https://codepen.io/zurfyx/pen/zYoVdRx?editors=1010

The logic for insertText(selection: Selection, text: string) is quite complex but I believe that ultimately we could compare trees and determine whether the native input would equal the computed input, and if that's the case favor the native over ours.

(Handling the spellchecker API ourselves doesn't look possible in Chrome and we would also have to handle each browser separately.)

cc @trueadm

@trueadm
Copy link
Collaborator

trueadm commented Mar 18, 2021

Good research :) I’ll look into this next week as it’s likely going to be quite involved.

@trueadm trueadm self-assigned this Mar 18, 2021
@trueadm trueadm changed the title Spellcheck triggers early because of custom insertText logic Bug: Spellcheck triggers early because of custom insertText logic Mar 22, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants