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

Prevent enter event while composing #900

Closed
d-sawada opened this issue Jun 25, 2019 · 3 comments · Fixed by #971
Closed

Prevent enter event while composing #900

d-sawada opened this issue Jun 25, 2019 · 3 comments · Fixed by #971

Comments

@d-sawada
Copy link

d-sawada commented Jun 25, 2019

Hello.

Description

Thank you for creating great components!
Now I was using v-select with multiple = true and taggable = false.
Entered Japanese to search for option and pressed Enter for conversion to kanji.
Then the enter event will be fired and option will be selected!
I want this problem to be solved.

Solution

Control enter events using two javascript events, compositionstart and compositionend.
Probably will be:

--- a/src/components/Select.vue
+++ b/src/components/Select.vue
@@ -428,6 +428,7 @@
       return {
         search: '',
         open: false,
+        composing: false,
         pushedTags: [],
         _value: [] // Internal value managed by Vue Select if no `value` prop is passed
       }
@@ -805,7 +806,7 @@
           case 13:
             //  enter.prevent
             e.preventDefault();
-            return this.typeAheadSelect();
+            return !this.composing && this.typeAheadSelect();
         }
       }
     },
@@ -883,6 +884,8 @@
               'value': this.search,
             },
             events: {
+              'compositionstart': (e) => this.composing = true,
+              'compositionend': (e) => this.composing = false,
               'keydown': this.onSearchKeyDown,
               'keyup': this.onSearchKeyUp,
               'blur': this.onSearchBlur,
@sagalbot
Copy link
Owner

sagalbot commented Nov 7, 2019

Thanks for bringing this one to my attention and providing such a detailed solution! I have just completed #971 that allows hooking into the search keydown handler. I will add this to that PR.

sagalbot added a commit that referenced this issue Nov 7, 2019
@sagalbot
Copy link
Owner

sagalbot commented Nov 7, 2019

In #971 I've also added the same check for !this.isComposing for the tab key. @d-sawada can you confirm if that is necessary?

@sagalbot sagalbot added this to To do in Triage via automation Nov 7, 2019
@sagalbot sagalbot moved this from To do to In progress in Triage Nov 7, 2019
@sagalbot
Copy link
Owner

sagalbot commented Mar 13, 2020

Marking this as closed by #971.

Triage automation moved this from In progress to Done Mar 13, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Triage
  
Done
Development

Successfully merging a pull request may close this issue.

2 participants