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

Windows - US International keyboard layout modifier (dead keys) don't correctly register #35086

Closed
kdevnel opened this issue Sep 23, 2021 · 14 comments · Fixed by #37777
Closed
Assignees
Labels
[Feature] Rich Text Related to the Rich Text component that allows developers to render a contenteditable [Status] In Progress Tracking issues with work in progress [Type] Bug An existing feature does not function as intended [Type] Regression Related to a regression in the latest release

Comments

@kdevnel
Copy link
Contributor

kdevnel commented Sep 23, 2021

Description

It appears when you have US International keyboard layouts active in Windows that the modifier keys (pressing either ' or ` on a US layout keyboard, followed by a letter such as e should then output either é or è) don't register correctly if you want to output the actual symbol character (usually done by clicking modifier + space).

Instead, it appears the editor outputs a space character only.

Step-by-step reproduction instructions

  1. Ensure you have US International keyboard selected in Windows (I tested with a US layout keyboard with US Internation selected in language settings)
  2. Create a new page or post
  3. Try out ' then e which should correctly output é
  4. Try out ' then space which should output the ' character but instead a space character is output instead.

Screenshots, screen recording, code snippet

Markup on 2021-09-23 at 14:59:42

Environment info

No response

Please confirm that you have searched existing issues in the repo.

Yes

Please confirm that you have tested with all plugins deactivated except Gutenberg.

No

@Flameeyes
Copy link

Looking at the history, I think e2e3f6b is probably related.
AIUI this uses the KeyboardEvent API that has specific behaviour for dead keys: https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key

(If that is the case, this may have the same problem on other non-Windows OSes, I just can't test that. macOS has an "US International (PC)" keyboard that uses dead keys the way Windows does, in Linux that's the US layout with alt-intl option.

@kdevnel
Copy link
Contributor Author

kdevnel commented Sep 27, 2021

macOS has an "US International (PC)" keyboard that uses dead keys the way Windows does

Just to add for context, I tested this with the US International (PC) on macOS and the behaviour of the dead keys is slightly different to how Windows handles them. The issue reported didn't happen in macOS for me, only on Windows.

The slight difference seems to be that in macOS, the first press of the modifier outputs a placeholder character that is then replaced with the final character on the second keypress. In Windows, the first press of the modifier doesn't output anything at all.

@Flameeyes
Copy link

So here's a JSFiddle that might be useful: http://jsfiddle.net/r8dMu/

The combination for á reports:

down   222 de Þ
up     222 de Þ
down   65 41 A
press  225 e1 á
up     65 41 A

While for ' it is:

down   222 de Þ
down   32 20  
press  39 27 '
up     222 de Þ
up     32 20  

You can see that there's five events for each character, because dead keys don't map 1-to-1 between keys and symbols. Most importantly the keydown/keyup don't match the press. Now, keypress is deprecated, so clearly this is not what is being used now.

But my JavaScript-fu is limited, @ellatrix any chance you have ideas on what may be causing this behaviour or a suggestion how to get this fixed quickly?

@simison
Copy link
Member

simison commented Sep 28, 2021

Cc @ellatrix @youknowriad

@youknowriad youknowriad added [Feature] Rich Text Related to the Rich Text component that allows developers to render a contenteditable [Type] Bug An existing feature does not function as intended labels Sep 28, 2021
@Flameeyes
Copy link

Further testing: this does not appear to affect Chrome on Android (of all things!). The output of the fiddle is (missing the last character because I'm manually re-typing), for á:

down 229 e5
up 229 e5

and for ':

down 229 e5
up 229 e5
up 32 20

@ellatrix
Copy link
Member

ellatrix commented Oct 5, 2021

Could you describe step by step what you're tying, what you're getting, and what you're expecting? You don't get the desired character after pressing space?

I tried on Mac and Chrome, Alt+´ works well.

@Flameeyes
Copy link

Flameeyes commented Oct 5, 2021

Could you describe step by step what you're tying, what you're getting, and what you're expecting? You don't get the desired character after pressing space?

Prerequisite: this is a report for Windows with the US International keyboard layout. Not Mac, not Android.

Using the US International layout, pressing a number of diacritical marks by themselves (no Alt, no Option, no Ctrl, no Compose) causes them to be interpreted as dead keys. That's true for `, ' ,", ~, ^.

Typing one of them following by a compatible letters should replace them with the appropriate codepoint, so for instance:

  • `a ⇒ à
  • ~n ⇒ ñ
  • "O ⇒ Ö

And to insert the actual diacritical mark, you type the dead key followed by SPACE;

  • "SPACE ⇒ "

This works everywhere: GitHub right now, Google Docs, Facebook, Instagram, Twitter, Gutenberg as of August, …

Except Gutenberg as of September.

I tried on Mac and Chrome, Alt+´ works well.

That is not what this report is about.

@Flameeyes
Copy link

Making sure that this issue is not considering "dormant" just because nobody said anything in a month.

@Flameeyes
Copy link

@youknowriad you may want to tag this as Regression as well — this works perfectly fine on older Gutenberg.

@youknowriad youknowriad added the [Type] Regression Related to a regression in the latest release label Nov 12, 2021
@Mamaduka
Copy link
Member

Mamaduka commented Jan 5, 2022

I'm removing this issue from WP 5.9 project board since RC1 was released last night.

Let's try and land a fix for this in a minor release.

@Flameeyes
Copy link

I guess I'll have to just stop using WordPress once 5.9 releases then.

I have to say I'm unimpressed by this whole experience. It's a clear, reproducible bug, affecting a major operating system (Windows!), and I even tracked down when the regression was introduced, but the only attention I got from developers has been looking at the wrong operating system.

Once again I feel that what killed blogging is not the death of Google Reader, but the rotting of writing options https://flameeyes.blog/2021/10/05/reader-is-dead-but-what-about-writers/

@mcsf
Copy link
Contributor

mcsf commented Jan 5, 2022

@Flameeyes: I am sorry about this one falling through the cracks and how it's impacting you.

I just spent the last couple of hours redoing my virtual machine setup (Win 10 VM guest on a macOS host with access to the host's dev server) and I can reproduce this issue. The expert in this domain, @ellatrix, is on leave, so we'll see if we can find a solution for this in the meantime.

@liamrosen
Copy link

Thanks, everyone who has been a squeaky wheel on this. I basically compose all of my Wordpress posts in Notepad++ at this point...

Looking forward to a fix soon!

@mcsf
Copy link
Contributor

mcsf commented Jan 6, 2022

I've tracked it down to #30244.

mcsf added a commit that referenced this issue Jan 7, 2022
See #35086

In `useSpace`, don't intercept character composition that involves the
Space key. For example, to input a standalone diacritic (like ´ or `)
using a keyboard with dead keys, one must first press the dead key and
then press the Space key.

Many operating systems handle this in such a way that the second
KeyboardEvent contains the property `keyCode: 229`. According to the
spec, 229 allows the system to indicate that an Input Method Editor
(IDE) is processing some key input.

However, Windows doesn't use `keyCode: 229` for dead key composition,
instead emitting an event with values `keyCode: SPACE` and `key: '´'`.
That is why checking the `key` property for values other than `SPACE`
is important.

This should serve as a reminder that the `KeyboardEvent.keyCode`
attribute is officially deprecated and that we should consider more
consistent interfaces.
@github-actions github-actions bot added the [Status] In Progress Tracking issues with work in progress label Jan 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Rich Text Related to the Rich Text component that allows developers to render a contenteditable [Status] In Progress Tracking issues with work in progress [Type] Bug An existing feature does not function as intended [Type] Regression Related to a regression in the latest release
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants