Skip to content

fix: transfer error when reset data in some cases#42785

Merged
zombieJ merged 12 commits intoant-design:masterfrom
BoyYangzai:fix-transfer
Jun 7, 2023
Merged

fix: transfer error when reset data in some cases#42785
zombieJ merged 12 commits intoant-design:masterfrom
BoyYangzai:fix-transfer

Conversation

@BoyYangzai
Copy link
Copy Markdown
Contributor

@BoyYangzai BoyYangzai commented Jun 1, 2023

[中文版模板 / Chinese template]

🤔 This is a ...

  • New feature
  • Bug fix
  • Site / documentation update
  • Demo update
  • Component style update
  • TypeScript definition update
  • Bundle size optimization
  • Performance optimization
  • Enhancement feature
  • Internationalization
  • Refactoring
  • Code style optimization
  • Test Case
  • Branch merge
  • Workflow
  • Other (about what?)

🔗 Related issue link

💡 Background and solution

📝 Changelog

Language Changelog
🇺🇸 English fix: transfer error when reset data in some cases
🇨🇳 Chinese 修复一些 cases 下重置数据出现 seletcedKeys 错误的情况

☑️ Self-Check before Merge

⚠️ Please check all items below before requesting a reviewing. ⚠️

  • Doc is updated/provided or not needed
  • Demo is updated/provided or not needed
  • TypeScript definition is updated/provided or not needed
  • Changelog is provided or not needed

🚀 Summary

🤖 Generated by Copilot at fe08ed8

Fixed a bug in the transfer component that caused an error when the data source and the target keys were reset. Added a test case to verify the fix and improved the logic of the useEffect hook in components/transfer/index.tsx.

🔍 Walkthrough

🤖 Generated by Copilot at fe08ed8

  • Fix error when reset data in transfer component (link, link, link)
  • Add imports of DefaultRecordType and Button in test file components/transfer/__tests__/index.test.tsx (link)
  • Modify useEffect hook in components/transfer/index.tsx to handle no props.selectedKeys case (link)
  • Add test case in components/transfer/__tests__/index.test.tsx to check no error when data source and target keys are reset by a button in the footer (link)

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Jun 1, 2023

Prepare preview

@codecov
Copy link
Copy Markdown

codecov bot commented Jun 1, 2023

Codecov Report

Patch coverage: 100.00% and no project coverage change.

Comparison is base (9b22fd4) 100.00% compared to head (1423192) 100.00%.

❗ Current head 1423192 differs from pull request most recent head b3a5f23. Consider uploading reports for the commit b3a5f23 to get more accurate results

Additional details and impacted files
@@            Coverage Diff            @@
##            master    #42785   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files          648       646    -2     
  Lines        10957     10935   -22     
  Branches      2976      2970    -6     
=========================================
- Hits         10957     10935   -22     
Impacted Files Coverage Δ
components/transfer/index.tsx 100.00% <100.00%> (ø)

... and 3 files 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.

@afc163
Copy link
Copy Markdown
Member

afc163 commented Jun 2, 2023

Comment thread components/transfer/index.tsx Outdated
Comment thread components/transfer/index.tsx Outdated
Comment thread components/transfer/index.tsx Outdated
@zombieJ
Copy link
Copy Markdown
Member

zombieJ commented Jun 2, 2023

感觉这个实现不太好,太多的 setSourceSelectedKeys,最好是直接给 sourceSelectedKeys 做个 memo 过滤,这样统一收口

Comment thread components/transfer/index.tsx Outdated
Comment thread components/transfer/index.tsx Outdated
Comment thread components/transfer/index.tsx Outdated
Comment thread components/transfer/index.tsx Outdated
Comment thread components/transfer/index.tsx Outdated
Comment thread components/transfer/index.tsx Outdated
Comment thread components/transfer/index.tsx Outdated
@zombieJ zombieJ merged commit 47f30ee into ant-design:master Jun 7, 2023
@zombieJ zombieJ mentioned this pull request Jun 19, 2023
16 tasks
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.

Transfer bug when resetting data

4 participants