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

[Component] [input, form] Result for characters calculate in el-input and in validation rules are different when unicode emoji in text #16756

Closed
tyuterry opened this issue May 6, 2024 · 0 comments · Fixed by #16757

Comments

@tyuterry
Copy link

tyuterry commented May 6, 2024

Bug Type: Component

Environment

  • Vue Version: 3.4.26
  • Element Plus Version: 2.7.2
  • Browser / OS: Chrome/124.0.0.0
  • Build Tool: Vite

Reproduction

Related Component

  • el-input
  • el-form

Reproduction Link

Element Plus Playground

Steps to reproduce

<template>
  <el-form
    ref="ruleFormRef"
    style="max-width: 600px"
    :model="ruleForm"
    :rules="rules"
  >
    <el-form-item label="name" prop="name">
      <el-input v-model="ruleForm.name" :show-word-limit="true" :maxlength="20" />
    </el-form-item>
  </el-form>
</template>

<script lang="ts" setup>
import { onMounted, reactive, ref } from 'vue'
import type { ComponentSize, FormInstance, FormRules } from 'element-plus'

interface RuleForm {
  name: string
}

const ruleFormRef = ref<FormInstance>()
const ruleForm = reactive<RuleForm>({
  name: '🥲'
})


const rules = reactive<FormRules<RuleForm>>({
  name: [
    { min: 2, message: 'el-input calculate character 2 but form rules think is 1', trigger: ['blur','change'] },
  ]
})


onMounted(()=>{
  ruleFormRef.value.validate()
})
</script>

What is Expected?

characters calculate result should be same

What is actually happening?

el-input calculate character is 2 but form rules think is 1

Additional comments

(empty)

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 a pull request may close this issue.

1 participant