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

input: fix cursor goes to the end when typing chinese quickly #11235

Merged
merged 1 commit into from
May 21, 2018

Conversation

STLighter
Copy link
Contributor

bugfix #11199

修改后在 window 7 / [chrome 66 | ie11] 下能正常使用. 受开发环境限制, 没有进行其他兼容性测试, 建议进一步测试.

另外没有处理韩文相关经验, commit里只简单保留了相关判断, 并简单用朝鲜语IME输入试了下没问题, 不太清楚对 #10611 是否有影响.

产生原因:
上一个文字键入后currentValue发生变化, 并在vue同步变化到dom前又迅速键入了其他字符, 触发输入法选择. 此时dom上的内容包括了新键入的字符, 但currentValue不包含.
vue将currentValue变化同步到dom上时将currenValue的值替换掉实际dom上的值使得光标跳到末尾处.

解决方案:
isOnCompositiontrue时也修改currentValue, 但不emit input事件和el.form.change事件, 保持内部currentValue与dom上value保持一致.
保存compositionstart事件触发时dom上的值到valueBeforeComposition, 在isOnCompositiontrue时只有新值与valueBeforeComposition不同时才能修改currentValue, 应对组件props.value的其他变动能正确反映到currentValue上.

其他修改:
由于input组件进行了composition相应处理, autocomplete无需再处理一次, 因此移除了相关处理.

autocomplete: remove composition event listeners because input has already handle it.
@element-bot
Copy link
Member

Deploy preview for element ready!

Built with commit b75d605

https://deploy-preview-11235--element.netlify.com

@STLighter STLighter changed the title input: cursor goes to the end when typing chinese quickly input: fix cursor goes to the end when typing chinese quickly May 21, 2018
Copy link
Contributor

@Leopoldthecoder Leopoldthecoder left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

已在 Safari、Firefox 测试通过

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.

3 participants