input: fix cursor goes to the end when typing chinese quickly #11235
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
bugfix #11199
修改后在
window 7 / [chrome 66 | ie11]
下能正常使用. 受开发环境限制, 没有进行其他兼容性测试, 建议进一步测试.另外没有处理韩文相关经验, commit里只简单保留了相关判断, 并简单用朝鲜语IME输入试了下没问题, 不太清楚对 #10611 是否有影响.
产生原因:
上一个文字键入后
currentValue
发生变化, 并在vue同步变化到dom前又迅速键入了其他字符, 触发输入法选择. 此时dom上的内容包括了新键入的字符, 但currentValue
不包含.vue将
currentValue
变化同步到dom上时将currenValue
的值替换掉实际dom上的值使得光标跳到末尾处.解决方案:
在
isOnComposition
为true
时也修改currentValue
, 但不emitinput
事件和el.form.change
事件, 保持内部currentValue
与dom上value
保持一致.保存
compositionstart
事件触发时dom上的值到valueBeforeComposition
, 在isOnComposition
为true
时只有新值与valueBeforeComposition
不同时才能修改currentValue
, 应对组件props.value
的其他变动能正确反映到currentValue
上.其他修改:
由于input组件进行了
composition
相应处理, autocomplete无需再处理一次, 因此移除了相关处理.