Skip to content

fix(TInput): password input keyboard issues on focus switch (#763)#928

Open
jamesliauw8-rgb wants to merge 2 commits into
Tencent:developfrom
jamesliauw8-rgb:fix/issue-763-password-keyboard
Open

fix(TInput): password input keyboard issues on focus switch (#763)#928
jamesliauw8-rgb wants to merge 2 commits into
Tencent:developfrom
jamesliauw8-rgb:fix/issue-763-password-keyboard

Conversation

@jamesliauw8-rgb
Copy link
Copy Markdown

Fixes the following issue reported in #763:
Switching focus between two TInput password fields causes the soft keyboard to be dismissed instead of staying open (Android).

Root cause:
TInputView passed onTapOutside straight through to TextField; when
callers do not provide one, Flutter's default _defaultOnTapOutside
unfocuses the current field, racing with the next field's
requestFocus and causing the keyboard to flicker shut.

Changes:

  • TInput: label-area GestureDetector now uses HitTestBehavior. translucent and forwards an explicit onLabelTap, so taps fall through to the underlying TextField when no label handler is supplied.
  • TInput / TInputView: add new optional autofillHints parameter and forward it to TextField for proper system password autofill support.
  • TInputView: provide a no-op default onTapOutside so switching between multiple TInputs no longer dismisses the soft keyboard. Callers can still override it to restore the dismiss-on-tap- outside behaviour.
  • example: add a login-style demo with two consecutive password inputs to manually verify the fix.
  • test: add 7 widget tests under test/input/ covering all fix points (all passing).

Verified on:

  • iOS 17 (manual + automated tests)
  • Android MIUI (Redmi, manual): focus-switch fix is effective.

Known upstream limitation (out of scope):
On MIUI / HyperOS, even a bare Flutter TextField(obscureText: true)
requires two taps to bring up the IME on first interaction. This is
a Flutter Engine + vendor IME compatibility issue and cannot be
worked around in Dart-layer component code.

🤔 这个 PR 的性质是?

勾选规则:
1.只要有新增参数,就勾选”新特性提交“
2.只修改内部bug,未新增参数,才勾选”日常 bug 修复“
3.其他选项视具体改动判断x

  • [ x] 日常 bug 修复
  • 新特性提交
  • 文档改进
  • 演示代码改进
  • 组件样式/交互改进
  • CI/CD 改进
  • 重构
  • 代码风格优化
  • 测试用例
  • 分支合并
  • 其他

🔗 相关 Issue

💡 需求背景和解决方案

📝 更新日志

  • fix(组件名称): 处理问题或特性描述 ...

  • 本条 PR 不需要纳入 Changelog

☑️ 请求合并前的自查清单

⚠️ 请自检并全部勾选全部选项⚠️

  • pr目标分支为develop分支,请勿直接往main分支合并
  • 标题格式为:组件类名: 修改描述(示例:TBottomTabBar: 修复iconText模式,底部溢出2.5像素)
  • ”相关issue“处带上修复的issue链接
  • 相关文档已补充或无须补充

)

Fixes the following issue reported in Tencent#763:
Switching focus between two TInput password fields causes the soft
keyboard to be dismissed instead of staying open (Android).

Root cause:
  TInputView passed onTapOutside straight through to TextField; when
  callers do not provide one, Flutter's default _defaultOnTapOutside
  unfocuses the current field, racing with the next field's
  requestFocus and causing the keyboard to flicker shut.

Changes:
  - TInput: label-area GestureDetector now uses HitTestBehavior.
    translucent and forwards an explicit onLabelTap, so taps fall
    through to the underlying TextField when no label handler is
    supplied.
  - TInput / TInputView: add new optional autofillHints parameter and
    forward it to TextField for proper system password autofill
    support.
  - TInputView: provide a no-op default onTapOutside so switching
    between multiple TInputs no longer dismisses the soft keyboard.
    Callers can still override it to restore the dismiss-on-tap-
    outside behaviour.
  - example: add a login-style demo with two consecutive password
    inputs to manually verify the fix.
  - test: add 7 widget tests under test/input/ covering all fix
    points (all passing).

Verified on:
  - iOS 17 (manual + automated tests)
  - Android MIUI (Redmi, manual): focus-switch fix is effective.

Known upstream limitation (out of scope):
  On MIUI / HyperOS, even a bare Flutter TextField(obscureText: true)
  requires two taps to bring up the IME on first interaction. This is
  a Flutter Engine + vendor IME compatibility issue and cannot be
  worked around in Dart-layer component code.
@tencent-adm
Copy link
Copy Markdown
Member

tencent-adm commented May 12, 2026

CLA assistant check
Thank you for your submission, we really appreciate it. Like many open source projects, we ask that you all sign our Contributor License Agreement before we can accept your contribution.
0 out of 2 committers have signed the CLA.

❌ williamliao
❌ autofix-ci[bot]


williamliao seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You have signed the CLA already but the status is still pending? Let us recheck it.

@github-actions
Copy link
Copy Markdown
Contributor

完成

📱 APK 下载

tdesign-flutter-0.2.7-498.apk

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.

2 participants