Repository navigation
Conversation
lnuxe
requested review from
anlyyao,
betavs,
jarmywang,
jin0209,
novlan1 and
zydemail
as code owners
November 16, 2026 09:41
lnuxe
force-pushed
the
fix/input-ime-flicker-4606
branch
from
November 17, 2026 02:04
f85d6a5 to
1018010
Compare
input/textarea 的 onInput 此前把每次 input 事件的中间态通过
setData({value}) 回写给原生控件;Mac 端韩语等 IME 组合输入时,
回写会打断输入法组合态(composition 被重置),造成内容反复
闪烁(issue Tencent#4606)。原生 input 组件无此问题,因为从不回写。
修复原则:输入过程中原生控件本就显示用户输入的中间态,
仅在限长(maxcharacter/maxlength)会截断内容时才回写做受控
纠偏;其余情况只按限长规则同步计数并抛出 change(携带原始值)。
- onInput 非截断分支不再 setData value(消除组合态打断源)
- 新增 calculateCount(input)/复用 calculateValue(textarea)
保证计数语义与截断分支一致
- updateValue 相同值短路:只同步计数不回写
- 新增 value 属性 observer:外部(父组件)受控更新仍同步到
内部展示,内部输入值不经过 observer,避免互相打断
- 回归测试按仓库单测规范并入 input/__test__/index.test.js(2 例)
lnuxe
force-pushed
the
fix/input-ime-flicker-4606
branch
from
November 23, 2026 08:01
1018010 to
693be0f
Compare
Author
|
分支已重建,说明一下改动: 之前这个分支是续在 现在已从
同时按仓库单测规范,把原先单独新增的 PR 描述也按 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
🤔 这个 PR 的性质是?
🔗 相关 Issue
Fixes #4606
💡 需求背景和解决方案
问题
Mac 端输入韩语时
t-input/t-textarea内容闪烁(见 issue 内录屏)。input、textarea 均存在;原生 input 组件没有此问题。根因
组件的
onInput把每次 input 事件的值通过setData({ value })回写,而 wxml 中<input value="{{value}}">又绑定该值——形成「原生输入 → setData 回写 → 原生重新应用 value」的回环。韩语等 IME 组合输入时,每个 keystroke 的中间态都触发一次回写;原生控件在组合会话进行中被重新应用 value 会重置 IME 组合态,导致文字反复消失/重绘,即肉眼可见的闪烁。原生 input 不回写,因此无此问题。
修复
核心原则:原生控件本就显示用户正在输入的中间态,无需回写确认。
setData({value})回写 → 打断 IMEinput 新增
calculateCount(与截断分支同一套 maxcharacter/maxlength 计数语义);textarea 直接复用既有calculateValue。验证
回归测试按仓库单测规范并入
packages/components/input/__test__/index.test.js(不单独新增测试文件):既有 maxcharacter 受控截断用例(CJK 计数等)全部保持通过。
📝 更新日志
tdesign-miniprogram