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 component defaultValue failed #2751

Merged
merged 2 commits into from
May 31, 2023

Conversation

Ricbet
Copy link
Member

@Ricbet Ricbet commented May 26, 2023

Types

  • 🐛 Bug Fixes

Background or solution

🤖 Generated by Copilot at 88e7ca1

  • Swap the order of value and defaultValue in the useState hooks for inputValue and preValue to fix a bug where the input value would not update when the value prop changes (link)

由于 value 值默认是 '' 空字符串,导致 defaultValue 值永远都不会生效,这里调整 defaultValue 和 value 的优先级

Changelog

🤖 Generated by Copilot at 88e7ca1

Fix a bug in the Input component that prevented it from responding to external value changes. Swap the order of value and defaultValue in the useState hooks for inputValue and preValue in Input.tsx.

@Ricbet Ricbet self-assigned this May 26, 2023
@opensumi opensumi bot added the 🐞 bug Something isn't working label May 26, 2023
@opensumi
Copy link
Contributor

opensumi bot commented May 26, 2023

ChatGPT Code Review:

代码的目的是修复一个 Input 组件中的 bug,bug 是当 value prop 改变时,input 的值不会更新。

解决方案是交换 Input 组件中 useState 钩子中 inputValue 和 preValue 的 value 和 defaultValue。

这个 diff 没有明显的错误或拼写错误。

@codecov
Copy link

codecov bot commented May 26, 2023

Codecov Report

Patch coverage has no change and project coverage change: -0.01 ⚠️

Comparison is base (834cb8e) 57.72% compared to head (cf22187) 57.72%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2751      +/-   ##
==========================================
- Coverage   57.72%   57.72%   -0.01%     
==========================================
  Files        1327     1327              
  Lines       83585    83585              
  Branches    17380    17380              
==========================================
- Hits        48253    48246       -7     
- Misses      32112    32118       +6     
- Partials     3220     3221       +1     
Flag Coverage Δ
jsdom 52.72% <ø> (-0.01%) ⬇️
node 16.79% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

see 1 file with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

packages/components/src/input/Input.tsx Outdated Show resolved Hide resolved
@Ricbet Ricbet force-pushed the fix/input-components-defaultValue branch from 88e7ca1 to cf22187 Compare May 30, 2023 10:40
@erha19 erha19 merged commit 69c6897 into main May 31, 2023
@erha19 erha19 deleted the fix/input-components-defaultValue branch May 31, 2023 02:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐞 bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants