What affects when Chrome begins to spell check a word?

49 views Asked by At

I'm trying to fix a bug with our current code, here is the issue. On one text input, when you begin typing, Chrome will not red underline the word until you press space.

But in another field, Chrome will automatically start highlighting the word in red as you type.

The goal is to have the latter field behave like the former (only highlight when the user has finished typing the word).

I'm trying to figure out what causes the difference between them. Code wise, they're both

<input type="text" autocomplete="off"/> with some other properties that I don't think will make a difference (one has a name, one has a name and an id).

(I've also done this on the same version of chrome, so I don't think that's the issue) Am I missing something obvious here? Thank you for any help.

1

There are 1 answers

2
twhb On

Though I can't tell if it's the case in your code, I encountered the same thing, and the answer was that Chrome spellchecks the current word whenever a script sets document.title, even to its current value. A mitigation is to manually de-dupe document.title changes like so:

function setDocumentTitle(value) {
  if (document.title !== value) {
    document.title = value;
  }
}

Reproduction: https://jsfiddle.net/twhb/6z89pnrq/

Bug report: https://bugs.chromium.org/p/chromium/issues/detail?id=772856