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

[Bug Report] Input word limit value not correct #6127

Closed
liunnn1994 opened this issue Feb 17, 2022 · 12 comments
Closed

[Bug Report] Input word limit value not correct #6127

liunnn1994 opened this issue Feb 17, 2022 · 12 comments

Comments

@liunnn1994
Copy link
Contributor

Element Plus version

2.0.2

OS/Browsers version

Windows 11
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/98.0.4758.102 Safari/537.36

Vue version

3.2.31

Reproduction Link

https://codepen.io/asdjgfr/pen/LYOeZGK

Steps to reproduce

paste or input some emoji such as 👩‍👩‍👧‍👧 or 🤰🏻

What is Expected?

👩‍👩‍👧‍👧 or 🤰🏻 should be calculated as 1

What is actually happening?

👩‍👩‍👧‍👧 compute as 7
🤰🏻 compute as 2

image

@bastarder
Copy link
Collaborator

😄!!!
i try "👩‍👩‍👧‍👧".length in chrome , get 11

@liunnn1994
Copy link
Contributor Author

😄!!! i try "👩‍👩‍👧‍👧".length in chrome , get 11

I have already created a new pull request to fixed and test it .

@xiaoxian521 xiaoxian521 linked a pull request Feb 17, 2022 that will close this issue
3 tasks
@sxzz
Copy link
Collaborator

sxzz commented Feb 21, 2022

I think it's by design. maxlength attribute also has the same effect.
WDYT /cc @JeremyWuuuuu

@liunnn1994
Copy link
Contributor Author

I think it's by design. maxlength attribute also has the same effect. WDYT /cc @JeremyWuuuuu

When I set maxlength to 10 and show-word-limit, input 👩‍👩‍👧‍👧 (four people) but got 👩‍👩‍👧‍ (three people) and 6 / 10 ,also only one more character can be inserted. It makes me confused. I saw another library, Ant Design Vue didn't have show-word-limit, Vuetify all props not supported 😂.

@jw-foss
Copy link
Member

jw-foss commented Feb 22, 2022

@sxzz @asdjgfr I think we should take @asdjgfr's proposal, since the emoji '👩‍👩‍👧‍' is constructed by
['👩', '‍', '👩', '‍', '👧', '‍'], the '' is a special symbol \uD83D which in fact takes 1 character length, so emoji '👩‍👩‍👧‍' should be length of 5 instead of '👩‍👩‍👧‍'.length === 8.

@liunnn1994
Copy link
Contributor Author

Can we merge this pr to close this issue? I have some problems in my project with this issue😂
@JeremyWuuuuu

@sxzz
Copy link
Collaborator

sxzz commented Mar 7, 2022

IMHO, I think the behavior should be consistent with JavaScript.

  • '👩‍👩‍👧‍👧'.length === 11
  • '🤰🏻'.length === 4

@liunnn1994
Copy link
Contributor Author

IMHO, I think the behavior should be consistent with JavaScript.

  • '👩‍👩‍👧‍👧'.length === 11
  • '🤰🏻'.length === 4

But for users, it can be typed like Chinese characters, also delete it with only one press.

@plainheart
Copy link
Member

FYI, I think it's correct behavior. Even though we change the rule to measure the length of the string that contains emoji characters to make the result expected to us, it's very possible that the database can't store the string as expected length. They just look like "one character". See also #6588 (comment).

@zt123123
Copy link
Contributor

@plainheart
我觉得你说的有道理,考虑很全面。 这个问题不做处理也无伤大雅。从实际业务场景来看,输入表情内容场景不多,至少应该优先保证数据存储没问题,后端程序不出错,前端follw规范就行了

@liunnn1994
Copy link
Contributor Author

closed. My opinion #6588 (comment)

@github-actions
Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

此 issue 已被自动锁定,因为关闭后没有任何近期活动。如果有相关 bug,请重新创建一个新 issue。

@github-actions github-actions bot locked and limited conversation to collaborators Apr 13, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants