nuxt / ui

A UI Library for Modern Web Apps, powered by Vue & Tailwind CSS.
https://ui.nuxt.com
MIT License
4.11k stars 542 forks source link

UInput Component Lacks Proper Handling of compositionstart and compositionend #2713

Open smile-alive opened 1 day ago

smile-alive commented 1 day ago

Environment

Version

v2.18.4

Reproduction

https://stackblitz.com/edit/nuxt-ui-8d9s2j?file=app.vue

Description

The UInput component does not handle compositionstart and compositionend events, resulting in issues for languages that rely on input composition, such as Chinese (e.g., Pinyin input). Vue’s default behavior for v-model on native input elements ensures that updates are delayed until the composition ends, preventing intermediate values from triggering updates. However, the UInput component currently lacks this mechanism, causing inconsistencies with Vue’s default form handling and leading to unexpected behavior during text composition.

Additional context

Image

<template>
    <input v-model="keyword" />
</template>

<script setup>
    const keyword = ref('');

    watchEffect(() => {
        console.log('🚀 ~ watchEffect ~ keyword.value:', keyword.value);
    });
</script>

Image

<template>
    <UInput v-model="keyword" />
</template>

<script setup>
    const keyword = ref('');

    watchEffect(() => {
        console.log('🚀 ~ watchEffect ~ keyword.value:', keyword.value);
    });
</script>

Logs