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

fix(input): controlled mode, content clearing does not work #1912

Merged
merged 5 commits into from
Feb 1, 2024

Conversation

oasis-cloud
Copy link
Collaborator

🤔 这个变动的性质是?

  • 日常 bug 修复
  • 站点、文档改进
  • 演示代码改进

🔗 相关 Issue

#1876

💡 需求背景和解决方案

通过 setState设置 value 为空,在移动设备上会先出触发按钮的 click 事件,然后才能触发 blur 事件,在 click 事件触发,并不能更新 blur 事件使用的值,所以需要将 blur 和 focus 改为使用 value 这个状态。

@oasis-cloud oasis-cloud changed the title fix(input): controlled mode, clearing content by setting an empty val… fix(input): controlled mode, content clearing does not work Jan 30, 2024
@@ -167,22 +167,18 @@ export const Input = forwardRef(
forceUpdate()
}

const handleFocus = (event: Event) => {
Copy link
Collaborator

Choose a reason for hiding this comment

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

这个改动,也可以用在 input.tsx 上。

@pull-request-size pull-request-size bot added size/L and removed size/M labels Feb 1, 2024
Copy link

codecov bot commented Feb 1, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (c4e7727) 76.30% compared to head (b9783dc) 76.56%.

Additional details and impacted files
@@            Coverage Diff             @@
##             next    #1912      +/-   ##
==========================================
+ Coverage   76.30%   76.56%   +0.26%     
==========================================
  Files         215      215              
  Lines        8794     8791       -3     
  Branches     2522     2521       -1     
==========================================
+ Hits         6710     6731      +21     
+ Misses       1886     1863      -23     
+ Partials      198      197       -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@oasis-cloud oasis-cloud merged commit 4b1c0e7 into jdf2e:next Feb 1, 2024
5 checks passed
@oasis-cloud oasis-cloud deleted the fix/input-onchange branch February 1, 2024 09:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Input受控模式,手动修改value后,onChange会自动触发,并传入上一个value的值
2 participants