Skip to content

Conversation

yaquawa
Copy link

@yaquawa yaquawa commented May 3, 2022

Languages like Japanese or Chinese input characters by something called IME. You may not familiar to this if you only input English characters, but people using IME will have trouble to "Add a new tag" by entering the "Enter" key, because the IME also use Enter key to confirm the user's current input which is different from regular Enter key.

You can use event.keyCode === 229 to detect if the event is triggered by IME or a regular Enter key.
This PR fix the bug by add the above logic to the Enter key handler.
(I have tested the code in my environment, which works great)

@hiromi2424
Copy link

Why this PR has been ignored about a half-year?
This is so great support to all languages IME needed.

In particular there is a workaround:

<script setup>
import { ref, onMounted } from 'vue';
import Multiselect from '@vueform/multiselect';

const multiselect = ref(null);
onMounted(() => {
  const defaultHandleKeydown = multiselect.value.handleKeydown;
  multiselect.value.handleKeydown = (e) => {
    if (e.key === 'Enter' && e.keyCode === 229) {
      e.preventDefault();
      return;
    }
    defaultHandleKeydown(e);
  };
});
</script>

<template>
  <Multiselect
    ref="multiselect"
    ...
  / >
</template>

But this is a very 'hucky' way that is not documented, not expected in usage and hard to read/understand.

Vue was developed under nations/cultures that uses IME, therefore libraries around Vue should respect such expectations.
I appreciate any actions from maintainers. thank you.

@ScopeyNZ
Copy link
Contributor

ScopeyNZ commented Nov 4, 2022

FYI I think the approriate way to do this with the KeyboardEvent API is to use the isComposing instance property: https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/isComposing

adamberecz added a commit that referenced this pull request Nov 21, 2022
@adamberecz
Copy link
Collaborator

Thanks for reporting and for the effort! As you PR doesn't contain tests I close it without merging, but the issue got fixed with your solution in 2.5.7.

@adamberecz adamberecz closed this Nov 21, 2022
@hiromi2424
Copy link

@adamberecz Thank you so much!!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants