-
-
Notifications
You must be signed in to change notification settings - Fork 457
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(select):解决分组时排序失效问题 #1055
fix(select):解决分组时排序失效问题 #1055
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
tests/Select.test.tsx
Outdated
open | ||
showSearch | ||
searchValue="entry" | ||
style={{ width: 100 }} | ||
placeholder="Search to Select" | ||
optionFilterProp="label" | ||
filterSort={ | ||
(optionA, optionB, info) => { | ||
if (!info.searchValue) return 0; | ||
const labelA = (optionA?.label ?? '').toLowerCase(); |
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.
缩进有点问题。
tests/Select.test.tsx
Outdated
expect(container.querySelector('.rc-select-item-option-grouped').textContent).toBe( | ||
'Entry', | ||
); | ||
}) |
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.
代码格式不太对,提交别加 --no-verify
很急,没进度了呀 |
Walkthrough此次更改引入了一个新的排序功能,用于根据搜索值增强选项的排序方式。通过递归地对选项进行排序,包括嵌套选项,优化了现有的过滤排序逻辑。此外,还增加了一个测试用例,以验证在提供搜索值和分组时, Changes
Assessment against linked issues
Poem
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-448
: 检查排序功能的性能和正确性新增的排序函数
sorter
用于处理嵌套选项的排序。请确保此函数在处理大量或深层嵌套的选项时,性能表现良好,并且递归逻辑没有引入额外的性能开销。建议添加一些针对嵌套选项的单元测试,以验证排序的正确性和效率。
453-453
: 验证排序函数在组件中的集成和条件逻辑在
orderedFilteredOptions
中使用sorter
函数的条件逻辑需要确保在没有提供filterSort
函数时,不会跳过必要的排序操作。此外,还应检查这种条件逻辑是否与组件的其他部分逻辑良好集成。tests/Select.test.tsx (1)
1950-1987
: 审查新的测试用例此测试用例专门针对分组选项的排序功能进行验证,与 PR 的目标直接相关。测试通过初始化一个带有
filterSort
函数和分组选项的Select
组件,并检查排序后的顶部选项是否符合预期。
- 代码格式:请注意,之前的评论提到了代码格式问题,建议检查并确保代码格式正确,遵循项目的代码风格指南。
- 分号使用:根据之前的机器人评论,建议在此测试用例中确保所有语句都显式使用分号,以保持代码的一致性。
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
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)
- src/Select.tsx (1 hunks)
Additional context used
Biome
src/Select.tsx
[error] 441-441: Expected a property, a shorthand property, a getter, a setter, or a method but instead found ')'.
Expected a property, a shorthand property, a getter, a setter, or a method here.
(parse)
[error] 441-441: expected
,
but instead found;
Remove ;
(parse)
Additional comments not posted (2)
src/Select.tsx (2)
434-442
: 代码看起来不错!新的
sorter
函数以一种干净和模块化的方式递归地对选项进行排序,包括嵌套选项。它利用现有的filterSort
函数,并正确处理嵌套选项。这改进了排序逻辑的可读性和可维护性。Tools
Biome
[error] 441-441: Expected a property, a shorthand property, a getter, a setter, or a method but instead found ')'.
Expected a property, a shorthand property, a getter, a setter, or a method here.
(parse)
[error] 441-441: expected
,
but instead found;
Remove ;
(parse)
447-447
: 代码修改看起来很好!对
orderedFilteredOptions
的修改很简单,并且正确地集成了新的sorter
函数。如果filterSort
不存在,它会保持返回filledSearchOptions
的现有行为。这些修改提高了代码的可读性和可维护性。
src/Select.tsx
Outdated
return sortedOptions.map((item) => ({ | ||
...item, | ||
options: Array.isArray(item.options) ? sorter(item.options) : item.options, | ||
); |
Check notice
Code scanning / CodeQL
Syntax error
src/Select.tsx
Outdated
return sortedOptions.map((item) => ({ | ||
...item, | ||
options: Array.isArray(item.options) ? sorter(item.options) : item.options, | ||
); |
Check notice
Code scanning / CodeQL
Syntax error
🤔 这个变动的性质是?
🔗 相关 Issue
ant-design/ant-design#50003
💡 需求背景和解决方案
fix ant-design/ant-design#50003
📝 更新日志
Summary by CodeRabbit
Summary by CodeRabbit
新功能
测试
Select
组件的filterSort
属性添加了新的测试用例,确保在提供搜索值和分组时,选项能够正确排序。