-
-
Notifications
You must be signed in to change notification settings - Fork 458
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: filterSort don't work on group item #1068
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
Walkthrough此次更改在 Changes
Assessment against linked issues
Tip We have updated our review workflow to use the Anthropic's Claude family of models. Please share any feedback in the discussion post on our Discord. Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (2)
- src/Select.tsx (1 hunks)
- tests/Select.test.tsx (1 hunks)
Additional comments not posted (3)
src/Select.tsx (2)
434-447
: 新的sorter
函数实现了递归排序这个新添加的
sorter
函数解决了分组选项排序的问题。它递归地处理嵌套选项,确保所有层级的选项都能正确排序。这是一个很好的改进,能够处理复杂的选项结构。建议考虑添加一些注释来解释函数的工作原理,特别是对于递归部分。
453-453
: 使用新的sorter
函数进行选项排序在
orderedFilteredOptions
useMemo 钩子中,现在使用新的sorter
函数来排序过滤后的选项。这个改动很好地利用了新的
sorter
函数,确保了所有选项(包括嵌套选项)都能正确排序。tests/Select.test.tsx (1)
1950-1984
: 测试用例覆盖了分组选项的过滤排序功能,看起来不错。这个测试用例很好地验证了
filterSort
在分组选项和搜索值存在时的行为。它确保了以搜索值开头的选项被优先排序。建议:为了增加可读性,可以考虑添加一个简短的注释,解释为什么期望 "Entry" 是第一个选项。例如:
// "Entry" 应该是第一个选项,因为它完全匹配搜索值 "entry" expect(container.querySelector('.rc-select-item-option-grouped').textContent).toBe('Entry');这样可以让其他开发者更容易理解测试的意图。
ci 挂了 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #1068 +/- ##
=======================================
Coverage 98.21% 98.22%
=======================================
Files 39 39
Lines 1460 1467 +7
Branches 432 411 -21
=======================================
+ Hits 1434 1441 +7
Misses 26 26 ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (1)
- src/Select.tsx (1 hunks)
Additional comments not posted (2)
src/Select.tsx (2)
453-453
: 使用新的sorter
函数来排序选项这个改动正确地应用了新的排序函数到过滤后的选项上。当提供了
filterSort
时,它能确保所有选项(包括嵌套选项)都能正确排序。
434-453
: 总结:新的排序实现有效解决了分组选项的排序问题这些更改很好地解决了 PR 目标中提到的分组选项排序失效的问题。新的
sorter
函数能够递归地处理嵌套选项,确保在所有层级上正确应用排序。这个实现不仅解决了当前的问题,而且提供了一个灵活的解决方案,可以处理各种复杂的选项结构。为了确保这些更改不会对其他功能产生意外影响,建议运行以下测试脚本:
这将帮助我们验证新的排序实现是否与组件的其他功能正常协作。
Verification successful
新的排序逻辑已通过测试验证
在
tests/Select.test.tsx
文件中,filterSort
函数的多个测试用例验证了其功能,包括与搜索值和分组时的行为。这些测试用例确认了新的排序逻辑已被测试覆盖。
tests/Select.test.tsx
: 包含filterSort
的测试用例。这些测试确保了新的排序实现与组件的其他功能正常协作。
Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # 描述:验证 Select 组件的所有现有测试用例是否仍然通过 # 测试:运行与 Select 组件相关的所有测试 npm test -- -t "Select"Length of output: 94
Script:
#!/bin/bash # Search for test files related to the Select component and display their contents fd -e ts -e tsx -e js -e jsx -e test -e spec | grep -i select | xargs catLength of output: 154282
Script:
#!/bin/bash # Search for occurrences of `filterSort` and `sorter` in test files to verify if the new sorting logic is explicitly tested rg 'filterSort|sorter' --glob '*.{ts,tsx,js,jsx}' --glob '!node_modules' --glob '!dist' --glob '!build'Length of output: 1268
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (1)
- tests/Select.test.tsx (1 hunks)
Files skipped from review as they are similar to previous changes (1)
- tests/Select.test.tsx
🤔 这个变动的性质是?
🔗 相关 Issue
ant-design/ant-design#50003
💡 需求背景和解决方案
fix ant-design/ant-design#50003
📝 更新日志
Summary by CodeRabbit
新功能
测试
filterSort
属性的功能是否正常。