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

fix(components): [input] update input value length calculate #11816

Merged
merged 2 commits into from
Mar 10, 2023

Conversation

btea
Copy link
Collaborator

@btea btea commented Mar 4, 2023

Please make sure these boxes are checked before submitting your PR, thank you!

  • Make sure you follow contributing guide English | (中文 | Español | Français).
  • Make sure you are merging your commits to dev branch.
  • Add some descriptions and refer to relative issues for your PR.

fix #11801

@github-actions
Copy link

github-actions bot commented Mar 4, 2023

@github-actions github-actions bot added the CommitMessage::Qualified Qualified commit message label Mar 4, 2023
@github-actions
Copy link

github-actions bot commented Mar 4, 2023

🧪 Playground Preview: https://element-plus.run/?pr=11816
Please comment the example via this playground if needed.

@ryuhangyeong
Copy link
Member

LGTM!

@jw-foss jw-foss merged commit b38607f into dev Mar 10, 2023
@jw-foss jw-foss deleted the fix/input-value-length branch March 10, 2023 06:52
@jw-foss
Copy link
Member

jw-foss commented Mar 10, 2023

@ryuhangyeong Thank you for reviewing PRs, many thanks ❤️ !!!

@fisker
Copy link

fisker commented Mar 14, 2023

Array.from() is used to fix #2653, now we break it again. So, if samilar issue report again, we'll change it back again? 👎 👎 👎

//cc @wen-haoming

@btea
Copy link
Collaborator Author

btea commented Mar 14, 2023

I think it is wrong to use Array.from here. If you encounter some complex emoji, such as 👨‍👨‍👦‍👦, the value of '👨‍👨‍👦‍👦'.length is 11, and the value of Array.from('👨‍👨‍👦‍👦').length is 7. So I think it is better to be consistent with the original.

If we need to deal with some special cases, perhaps we can provide an additional attribute to receive a function, allowing users to customize the character length calculation rules. I think this should be better.

@fisker
Copy link

fisker commented Mar 14, 2023

Of course Array.from is wrong, Intl.Segmenter#segment should be preferred, but I agree it should be configurable to pass a function to calculate length.

I'm fine to use .length as the default. I'm unhappy only because no one checks the history, it's so obvious that original code write in this way on purpose.

loosheng pushed a commit to loosheng/element-plus that referenced this pull request Mar 26, 2023
…-plus#11816)

* fix(components): [input] update input value length calculate

* fix: update test
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Component] [input] el-input 组件在有表情输入的情况下,统计字数显示错误
4 participants