]> cat aescling's git repositories - mastodon.git/commitdiff
Ignore keyevents during text composition (#7205)
authorunarist <m.unarist@gmail.com>
Fri, 20 Apr 2018 16:36:52 +0000 (01:36 +0900)
committerEugen Rochko <eugen@zeonfederated.com>
Fri, 20 Apr 2018 16:36:52 +0000 (18:36 +0200)
KeyboardEvent.key may be physical key name (Escape, Tab, etc.)
even in text composition and it causes hotkeys or suggestion selection.
So we need to check e.which or e.isComposing.

Checking e.which also allows us to avoid Esc key on compositionend in Safari.

app/javascript/mastodon/components/autosuggest_textarea.js

index 5474771c9927e854072f9e72e84eb93d8f3bc15f..a4f5cf50c65ae1a3b41d3d2294977e09a05abb69 100644 (file)
@@ -84,6 +84,12 @@ export default class AutosuggestTextarea extends ImmutablePureComponent {
       return;
     }
 
+    if (e.which === 229 || e.isComposing) {
+      // Ignore key events during text composition
+      // e.key may be a name of the physical key even in this case (e.x. Safari / Chrome on Mac)
+      return;
+    }
+
     switch(e.key) {
     case 'Escape':
       if (suggestions.size === 0 || suggestionsHidden) {