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]: Renderer spellcheck API does not work on Windows #28404

Closed
3 tasks done
lishid opened this issue Mar 26, 2021 · 6 comments
Closed
3 tasks done

[Bug]: Renderer spellcheck API does not work on Windows #28404

lishid opened this issue Mar 26, 2021 · 6 comments
Labels
12-x-y bug 🪲 component/spellcheck has-repro-gist Issue can be reproduced with code at https://gist.github.com/ platform/windows

Comments

@lishid
Copy link
Contributor

lishid commented Mar 26, 2021

Preflight Checklist

Electron Version

12.0.2

What operating system are you using?

Windows

Operating System Version

Windows 10 1909

What arch are you using?

x64

Last Known Working Electron version

No response

Expected Behavior

renderer.js

let element = document.createElement('textarea');
element.spellcheck = true;
element.value = 'testt';
document.body.appendChild(element);
element.focus();

setInterval(() => {
  console.log(require('electron').webFrame.isWordMisspelled('testt'))
}, 1000);

Expected: Console log repeatedly print "true"

Actual Behavior

Actual: Console log repeatedly prints "false"

Testcase Gist URL

(edit ckerr): https://gist.github.com/ckerr/91b84f22d5beeef1506174b495720dd7

Concerning the API released in #25060

@zcbenz Noticed you were working on spellcheck related tests. It seems that the tests for this API don't run on Windows so it wasn't caught:

const shouldRun = process.platform !== 'win32';

This seems to work on Linux for me, but not on Windows.

@lishid
Copy link
Contributor Author

lishid commented Mar 26, 2021

This comment might be related:
https://github.com/electron/electron/pull/25060/files#r496156887

@ckerr
Copy link
Member

ckerr commented Mar 29, 2021

Confirmed works on Linux. Tested with Electron 12.0.2 on Ubuntu 20.10.

Electron fiddle test: https://gist.github.com/ckerr/91b84f22d5beeef1506174b495720dd7

@ckerr ckerr added has-repro-gist Issue can be reproduced with code at https://gist.github.com/ platform/windows labels Mar 29, 2021
@codebytere codebytere reopened this Mar 30, 2021
@codebytere
Copy link
Member

This is because by default the spellchecker only automatically detects language on macOS - see:

#### `ses.setSpellCheckerLanguages(languages)`
* `languages` String[] - An array of language codes to enable the spellchecker for.
The built in spellchecker does not automatically detect what language a user is typing in. In order for the
spell checker to correctly check their words you must call this API with an array of language codes. You can
get the list of supported language codes with the `ses.availableSpellCheckerLanguages` property.
**Note:** On macOS the OS spellchecker is used and will detect your language automatically. This API is a no-op on macOS.

If you add session.defaultSession.setSpellCheckerLanguages(['en-US']) to your Fiddle before you create the window the test will pass.

@lishid
Copy link
Contributor Author

lishid commented Mar 31, 2021

I have tried adding session.defaultSession.setSpellCheckerLanguages(['en-US']) in my fiddle right before new BrowserWindow but I can still repro this issue.

An observation is that Electron correctly spellchecks the textarea with English, without having to set the language, but the API still returns false on the identically misspelled word.

image

@lishid
Copy link
Contributor Author

lishid commented Apr 2, 2021

@codebytere Can you verify/repro this on Windows?

@lishid
Copy link
Contributor Author

lishid commented Apr 8, 2021

@ckerr Any chance we can have this re-opened?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
12-x-y bug 🪲 component/spellcheck has-repro-gist Issue can be reproduced with code at https://gist.github.com/ platform/windows
Projects
None yet
Development

No branches or pull requests

3 participants