about summary refs log tree commit diff
diff options
context:
space:
mode:
authorunarist <m.unarist@gmail.com>2018-04-21 01:36:52 +0900
committerEugen Rochko <eugen@zeonfederated.com>2018-04-20 18:36:52 +0200
commit84214b864c63aee08357a719ab386b8e4ed5b901 (patch)
tree1bf4fb44822e8f1fa0b9bedab66ef811bef49220
parent87e3f0a41d2a2d223c663365a199c01989afc8ed (diff)
Ignore keyevents during text composition (#7205)
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.
-rw-r--r--app/javascript/mastodon/components/autosuggest_textarea.js6
1 files changed, 6 insertions, 0 deletions
diff --git a/app/javascript/mastodon/components/autosuggest_textarea.js b/app/javascript/mastodon/components/autosuggest_textarea.js
index 5474771c9..a4f5cf50c 100644
--- a/app/javascript/mastodon/components/autosuggest_textarea.js
+++ b/app/javascript/mastodon/components/autosuggest_textarea.js
@@ -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) {