-
-
Notifications
You must be signed in to change notification settings - Fork 145
feat: retire deprecated api and rename to popup #558
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
Conversation
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
Walkthrough本次更新主要对 Cascader 组件及相关工具、测试和示例中的属性名称与废弃逻辑进行了调整。将部分属性从 “dropdown” 重命名为 “popup”,例如将 Changes
Sequence Diagram(s)sequenceDiagram
participant Demo
participant Cascader
Demo->>Cascader: 传入 open 与 onPopupVisibleChange
Cascader-->>Demo: 触发 onPopupVisibleChange
Demo->>Demo: 调用 setOpen 更新状态
Suggested reviewers
Poem
Warning There were issues while running some tools. Please review the errors and either fix the tool’s configuration or disable the tool if it’s a critical failure. 🔧 ESLint
src/hooks/useSelect.tsOops! Something went wrong! :( ESLint: 8.57.1 ESLint couldn't find the config "prettier" to extend from. Please check that the name of the config is correct. The config "prettier" was referenced from the config file in "/.eslintrc.js". If you still have problems, please stop by https://eslint.org/chat/help to chat with the team. src/hooks/useValues.tsOops! Something went wrong! :( ESLint: 8.57.1 ESLint couldn't find the config "prettier" to extend from. Please check that the name of the config is correct. The config "prettier" was referenced from the config file in "/.eslintrc.js". If you still have problems, please stop by https://eslint.org/chat/help to chat with the team. src/utils/treeUtil.tsOops! Something went wrong! :( ESLint: 8.57.1 ESLint couldn't find the config "prettier" to extend from. Please check that the name of the config is correct. The config "prettier" was referenced from the config file in "/.eslintrc.js". If you still have problems, please stop by https://eslint.org/chat/help to chat with the team. ✨ Finishing Touches
🪧 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 (
|
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #558 +/- ##
==========================================
- Coverage 99.83% 99.83% -0.01%
==========================================
Files 23 23
Lines 610 603 -7
Branches 186 184 -2
==========================================
- Hits 609 602 -7
Misses 1 1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
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
🧹 Nitpick comments (1)
src/utils/warningNullOptions.ts (1)
5-26: 递归检查空值的实现合理,但可改进
warningNullOptions使用递归查找选项中的value是否为null并对外发出警告,能有效防止无效值。若需要更严格的校验,可在发现无效项后立即抛出错误或收集无效项路径,便于排查。
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (5)
examples/visible.tsx(2 hunks)src/Cascader.tsx(6 hunks)src/utils/warningNullOptions.ts(1 hunks)src/utils/warningPropsUtil.ts(0 hunks)tests/index.spec.tsx(2 hunks)
💤 Files with no reviewable changes (1)
- src/utils/warningPropsUtil.ts
🔇 Additional comments (11)
src/Cascader.tsx (6)
27-27: 导入新工具函数检查空值非常有用
此处引入了warningNullOptions用于捕获value为null的无效选项,逻辑清晰且与后续警告机制相匹配。
101-101: 新增属性用于替代 popupVisible
添加了open?: boolean;等新字段,取代了原先的popupVisible,增强了可读性与语义清晰度。
128-129: 类型判定逻辑可读性良好
此处的三元运算确保了根据泛型类型自动推导返回值类型,无明显问题。
414-415: 逻辑判断简洁
当选项为空时,通过emptyOptions条件分支维持下拉菜单宽度,符合组件的 UI 需求。
418-419: 自定义最小宽度
设置minWidth: 'auto'在空或搜索场景下避免强制固定宽度,展示灵活。
447-449: 新增下拉菜单控制属性
使用新的open,dropdownClassName和placement替代旧属性,接口更直观一致,值得赞赏。examples/visible.tsx (3)
62-62: 本地状态名更具可读性
将popupVisible替换为open,变量名更简洁,符合更通用的命名规范。
72-72: 使用新属性 open
此处改为open={open},与最新 API 相匹配,也与命名风格保持一致。
75-75: 可见性变更回调更新
将onPopupVisibleChange替换为onDropdownVisibleChange,符合新版属性命名,逻辑更简明。tests/index.spec.tsx (2)
581-581: 测试用例中使用 open 属性
将测试组件改用open,确保对新属性的可见性逻辑进行正确验证。
593-593: 保持与最新 API 接口一致
测试里直接使用open并添加自定义dropdownRender,与现有的下拉控制逻辑对应,测试覆盖面完整。
cce7431 to
646ca89
Compare
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: 2
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (5)
docs/demo/open.md(1 hunks)examples/open.tsx(2 hunks)src/Cascader.tsx(2 hunks)src/utils/warningPropsUtil.ts(1 hunks)tests/index.spec.tsx(3 hunks)
✅ Files skipped from review due to trivial changes (1)
- docs/demo/open.md
🚧 Files skipped from review as they are similar to previous changes (1)
- src/Cascader.tsx
🔇 Additional comments (4)
examples/open.tsx (2)
62-62: 状态变量名称更新符合新的 API 规范使用
open替代popupVisible的改动符合组件 API 的最新规范。
72-75: Props 命名更新完整且一致组件属性从
popupVisible和onPopupVisibleChange更新为open和onPopupVisibleChange的改动保持了一致性。src/utils/warningPropsUtil.ts (1)
5-5: 属性解构更新符合新的 API 设计从 props 中解构出
onDropdownVisibleChange和dropdownClassName符合新的 API 命名规范。tests/index.spec.tsx (1)
607-607: 测试用例中的 open 属性使用正确测试用例正确使用了新的
open属性替代popupVisible。Also applies to: 619-619
src/utils/warningPropsUtil.ts
Outdated
| !onDropdownVisibleChange, | ||
| '`onDropdownVisibleChange` is deprecated. Please use `onPopupVisibleChange` instead.', |
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.
警告信息需要调整
警告信息中的新旧 API 名称似乎颠倒了:
- 声明
onDropdownVisibleChange已废弃,建议使用onPopupVisibleChange - 声明
dropdownClassName已废弃,建议使用popupClassName
这与实际的 API 迁移方向(从 popup 到 dropdown)相反。
建议修改为:
- !onDropdownVisibleChange,
- '`onDropdownVisibleChange` is deprecated. Please use `onPopupVisibleChange` instead.',
+ !onPopupVisibleChange,
+ '`onPopupVisibleChange` is deprecated. Please use `onDropdownVisibleChange` instead.',
- dropdownClassName === undefined,
- '`dropdownClassName` is deprecated. Please use `popupClassName` instead.',
+ popupClassName === undefined,
+ '`popupClassName` is deprecated. Please use `dropdownClassName` instead.',Also applies to: 12-13
tests/index.spec.tsx
Outdated
| it('onDropdownVisibleChange & dropdownClassName', () => { | ||
| resetWarned(); | ||
| const errorSpy = jest.spyOn(console, 'error').mockImplementation(() => {}); | ||
| const onPopupVisibleChange = jest.fn(); | ||
| const onDropdownVisibleChange = jest.fn(); | ||
| const wrapper = mount( | ||
| <Cascader | ||
| popupVisible | ||
| onPopupVisibleChange={onPopupVisibleChange} | ||
| popupClassName="legacy-cls" | ||
| popupPlacement="topRight" | ||
| open | ||
| onDropdownVisibleChange={onDropdownVisibleChange} | ||
| dropdownClassName="legacy-cls" | ||
| placement="topRight" | ||
| />, | ||
| ); | ||
|
|
||
| expect(errorSpy).toHaveBeenCalledWith( | ||
| 'Warning: `onPopupVisibleChange` is deprecated. Please use `onDropdownVisibleChange` instead.', | ||
| ); | ||
| expect(errorSpy).toHaveBeenCalledWith( | ||
| 'Warning: `popupVisible` is deprecated. Please use `open` instead.', | ||
| 'Warning: `onDropdownVisibleChange` is deprecated. Please use `onPopupVisibleChange` instead.', | ||
| ); | ||
| expect(errorSpy).toHaveBeenCalledWith( | ||
| 'Warning: `popupClassName` is deprecated. Please use `dropdownClassName` instead.', | ||
| ); | ||
| expect(errorSpy).toHaveBeenCalledWith( | ||
| 'Warning: `popupPlacement` is deprecated. Please use `placement` instead.', | ||
| 'Warning: `dropdownClassName` is deprecated. Please use `popupClassName` instead.', |
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.
测试用例需要更新以匹配新的 API 变更
测试用例中的断言与实际的 API 迁移方向不符:
- 测试用例使用新 API(
onDropdownVisibleChange)但期望看到废弃警告 - 警告信息的断言与实际迁移方向相反
建议修改测试用例:
- expect(errorSpy).toHaveBeenCalledWith(
- 'Warning: `onDropdownVisibleChange` is deprecated. Please use `onPopupVisibleChange` instead.',
- );
+ expect(errorSpy).toHaveBeenCalledWith(
+ 'Warning: `onPopupVisibleChange` is deprecated. Please use `onDropdownVisibleChange` instead.',
+ );
- expect(errorSpy).toHaveBeenCalledWith(
- 'Warning: `dropdownClassName` is deprecated. Please use `popupClassName` instead.',
- );
+ expect(errorSpy).toHaveBeenCalledWith(
+ 'Warning: `popupClassName` is deprecated. Please use `dropdownClassName` instead.',
+ );Committable suggestion skipped: line range outside the PR's diff.
646ca89 to
5851494
Compare
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: 4
🔭 Outside diff range comments (2)
src/OptionList/List.tsx (1)
73-73:⚠️ Potential issue修复TypeScript类型错误
管道构建失败显示这几行存在类型错误。参数类型
Key[]不能赋值给参数类型SingleValueType,因为Key类型中的bigint不能赋值给string | number类型。应该对这些函数调用进行类型转换或修改相关类型定义。可以尝试以下修复方案:
- internalLoadData(valueCells); + internalLoadData(valueCells as (string | number)[]); - const pathKey = toPathKey(valueCells); + const pathKey = toPathKey(valueCells as (string | number)[]); - const cellKeyPath = toPathKey(cellPath); + const cellKeyPath = toPathKey(cellPath as (string | number)[]);Also applies to: 78-78, 194-194
🧰 Tools
🪛 GitHub Actions: ✅ test
[error] 73-73: TS2345: Argument of type 'Key[]' is not assignable to parameter of type 'SingleValueType'. Type 'Key' is not assignable to type 'string | number'. Type 'bigint' is not assignable to type 'string | number'.
tests/private.spec.tsx (1)
6-6: 🛠️ Refactor suggestion测试名称与属性不一致
测试名称仍然是
dropdownPrefixCls,但实际测试的属性已经改为popupPrefixCls。测试名称应当与正在测试的属性保持一致。- it('dropdownPrefixCls', () => { + it('popupPrefixCls', () => {Also applies to: 24-24
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (10)
examples/visible.tsx(2 hunks)package.json(1 hunks)src/Cascader.tsx(11 hunks)src/OptionList/Column.tsx(2 hunks)src/OptionList/List.tsx(1 hunks)src/Panel.tsx(1 hunks)src/context.ts(1 hunks)src/utils/warningPropsUtil.ts(1 hunks)tests/index.spec.tsx(3 hunks)tests/private.spec.tsx(1 hunks)
✅ Files skipped from review due to trivial changes (3)
- src/OptionList/Column.tsx
- src/context.ts
- src/Panel.tsx
🧰 Additional context used
🪛 GitHub Actions: ✅ test
src/OptionList/List.tsx
[error] 73-73: TS2345: Argument of type 'Key[]' is not assignable to parameter of type 'SingleValueType'. Type 'Key' is not assignable to type 'string | number'. Type 'bigint' is not assignable to type 'string | number'.
[error] 78-78: TS2345: Argument of type 'Key[]' is not assignable to parameter of type 'SingleValueType'. Type 'Key' is not assignable to type 'string | number'. Type 'bigint' is not assignable to type 'string | number'.
[error] 194-194: TS2345: Argument of type 'Key[]' is not assignable to parameter of type 'SingleValueType'. Type 'Key' is not assignable to type 'string | number'. Type 'bigint' is not assignable to type 'string | number'.
🔇 Additional comments (10)
src/OptionList/List.tsx (1)
57-57: API重命名:从dropdown更名为popup
dropdownPrefixCls已更名为popupPrefixCls,这符合PR的目标,即统一使用更新后的API命名。这个变更与组件中的其他更改保持一致。Also applies to: 62-62
src/utils/warningPropsUtil.ts (1)
1-2: 成功移除废弃的API警告此更改移除了
warningProps函数及其相关导入,这是符合PR目标的,即完全移除已经废弃的API。保留warningNullOptions函数是正确的,因为该函数仍然具有验证选项值有效性的作用。examples/visible.tsx (2)
62-62: 状态变量名称更新正确。将状态变量从
popupVisible更新为open符合组件 API 的更新方向。
72-72: 属性名称更新正确。将
popupVisible属性更新为open符合组件 API 的更新方向。src/Cascader.tsx (4)
27-27: 导入更新正确。移除了不再需要的
warningProps导入,仅保留warningNullOptions。
98-98: 属性名称更新正确。将
dropdownPrefixCls更新为popupPrefixCls符合组件 API 的更新方向。
366-367: 变量合并逻辑正确。正确处理了新旧 API 的兼容逻辑,优先使用
popupMenuColumnStyle,如果不存在则回退到dropdownMenuColumnStyle。
452-455: 属性使用更新正确。使用
open替代popupVisible,使用placement替代popupPlacement,符合组件 API 的更新方向。tests/index.spec.tsx (2)
599-602: 使用新的 API 属性名称正确使用了
open属性替代旧的popupVisible属性。
609-612: 使用新的 API 属性名称正确使用了
open属性替代旧的popupVisible属性。
package.json
Outdated
| "@types/enzyme": "^3.1.15", | ||
| "@types/jest": "^29.4.0", | ||
| "@types/react": "^17.0.38", | ||
| "@types/react": "^18.0.38", |
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.
💡 Verification agent
🧩 Analysis chain
React类型定义版本更新
此更改将 @types/react 的版本从 ^17.0.38 更新到了 ^18.0.38,这是一个主要版本更新。确保项目中的其他依赖和代码与 React 18 的类型定义兼容。
🏁 Script executed:
#!/bin/bash
# 检查 React 依赖版本与类型定义版本是否匹配
grep -E '"react": ".*"' package.json
grep -E '"react-dom": ".*"' package.json
grep -E '"@types/react": ".*"' package.json
grep -E '"@types/react-dom": ".*"' package.jsonLength of output: 350
React类型定义版本升级存在依赖版本不匹配问题
当前仅升级了 @types/react(及相应的 @types/react-dom)至 React 18 的类型定义,但项目中的 react 与 react-dom 依然是 React 16 的版本。这种不一致可能引发类型或运行时的问题。建议同步更新 react 与 react-dom 至 React 18 版本,或确保项目代码与新版类型定义保持兼容。
- 请检查并更新 package.json 中的
react与react-dom至兼容 React 18 的版本
| value={value} | ||
| options={addressOptions} | ||
| onPopupVisibleChange={open => setPopupVisible(open)} | ||
| onPopupVisibleChange={open => setOpen(open)} |
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.
💡 Verification agent
🧩 Analysis chain
事件处理器更新不完整
根据 PR 的目标是废弃旧 API,onPopupVisibleChange 也应该更新为新的 API 名称。
- onPopupVisibleChange={open => setOpen(open)}
+ onDropdownVisibleChange={open => setOpen(open)}🏁 Script executed:
#!/bin/bash
# 检查 src/Cascader.tsx 中 onPopupVisibleChange 和 onDropdownVisibleChange 的使用情况
grep -n "onPopupVisibleChange\|onDropdownVisibleChange" src/Cascader.tsxLength of output: 267
请更新所有事件处理器引用
根据最新的检查,在 examples/visible.tsx(第 75 行)以及 src/Cascader.tsx 中(例如第 109、212、363 和 455 行)的代码依然使用了旧 API onPopupVisibleChange。而本次 PR 的目标是废弃旧 API,因此需要将所有相关引用统一更新为新版 API onDropdownVisibleChange。
示例修改差异:
- onPopupVisibleChange={open => setOpen(open)}
+ onDropdownVisibleChange={open => setOpen(open)}请同步检查并更新 src/Cascader.tsx 中所有涉及该事件处理器的位置,以确保整个代码库的一致性。
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| onPopupVisibleChange={open => setOpen(open)} | |
| onDropdownVisibleChange={open => setOpen(open)} |
| popupClassName?: string; | ||
| /** @deprecated Use `popupMenuColumnStyle` instead */ | ||
| dropdownMenuColumnStyle?: React.CSSProperties; | ||
| popupMenuColumnStyle?: React.CSSProperties; |
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.
❓ Verification inconclusive
缺少类名属性更新
popupClassName 属性应该标记为过时,并添加 dropdownClassName 作为新的 API。根据之前的评审意见,类名也需要更新。
popupClassName?: string;
+/** @deprecated Use `dropdownClassName` instead */🏁 Script executed:
#!/bin/bash
# 检查测试中是否使用了 dropdownClassName
grep -n "dropdownClassName" tests/index.spec.tsxLength of output: 48
请更新类名属性和相关测试用例
- 在文件
src/Cascader.tsx中,将popupClassName属性标记为过时,并新增dropdownClassName属性作为替代方案。 - 根据已有评审意见,需要在代码中添加如下变更:
popupClassName?: string; +/** @deprecated 使用 `dropdownClassName` 代替 */ +dropdownClassName?: string;
- 请注意,目前在测试文件
tests/index.spec.tsx中没有发现dropdownClassName的使用。请务必手动检查或更新相关测试,确保新 API 能覆盖所有预期场景。
Committable suggestion skipped: line range outside the PR's diff.
tests/index.spec.tsx
Outdated
| it('warning onPopupVisibleChange & popupClassName', () => { | ||
| resetWarned(); | ||
| const errorSpy = jest.spyOn(console, 'error').mockImplementation(() => {}); | ||
| const onPopupVisibleChange = jest.fn(); | ||
| const wrapper = mount( | ||
| <Cascader | ||
| popupVisible | ||
| open | ||
| onPopupVisibleChange={onPopupVisibleChange} | ||
| popupClassName="legacy-cls" | ||
| popupPlacement="topRight" | ||
| placement="topRight" | ||
| />, |
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.
测试用例与 API 更新方向不一致
测试用例的描述和使用的属性与实际 API 迁移方向不符:
- 测试描述仍然使用
onPopupVisibleChange而非onDropdownVisibleChange - 使用
popupClassName而非dropdownClassName
根据 PR 的目标是废弃旧 API,测试用例应该使用新的 API 名称。
- it('warning onPopupVisibleChange & popupClassName', () => {
+ it('warning onDropdownVisibleChange & dropdownClassName', () => {
resetWarned();
const errorSpy = jest.spyOn(console, 'error').mockImplementation(() => {});
const onPopupVisibleChange = jest.fn();
const wrapper = mount(
<Cascader
open
- onPopupVisibleChange={onPopupVisibleChange}
- popupClassName="legacy-cls"
+ onDropdownVisibleChange={onPopupVisibleChange}
+ dropdownClassName="legacy-cls"
placement="topRight"
/>,
);📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| it('warning onPopupVisibleChange & popupClassName', () => { | |
| resetWarned(); | |
| const errorSpy = jest.spyOn(console, 'error').mockImplementation(() => {}); | |
| const onPopupVisibleChange = jest.fn(); | |
| const wrapper = mount( | |
| <Cascader | |
| popupVisible | |
| open | |
| onPopupVisibleChange={onPopupVisibleChange} | |
| popupClassName="legacy-cls" | |
| popupPlacement="topRight" | |
| placement="topRight" | |
| />, | |
| it('warning onDropdownVisibleChange & dropdownClassName', () => { | |
| resetWarned(); | |
| const errorSpy = jest.spyOn(console, 'error').mockImplementation(() => {}); | |
| const onPopupVisibleChange = jest.fn(); | |
| const wrapper = mount( | |
| <Cascader | |
| open | |
| onDropdownVisibleChange={onPopupVisibleChange} | |
| dropdownClassName="legacy-cls" | |
| placement="topRight" | |
| />, | |
| ); |
|
New, updated, and removed dependencies detected. Learn more about Socket for GitHub ↗︎
|
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
Plan: Pro
📒 Files selected for processing (4)
package.json(3 hunks)src/hooks/useEntities.ts(1 hunks)src/hooks/useSelect.ts(1 hunks)src/hooks/useValues.ts(1 hunks)
✅ Files skipped from review due to trivial changes (3)
- src/hooks/useValues.ts
- src/hooks/useSelect.ts
- src/hooks/useEntities.ts
⏰ Context from checks skipped due to timeout of 90000ms (1)
- GitHub Check: test / react component workflow
🔇 Additional comments (3)
package.json (3)
36-36: 新增 tsc 脚本命令
该命令"tsc": "bunx tsc --noEmit"用于执行 TypeScript 的静态类型检查而不产生输出文件。请确认所有构建环境均支持 Bun 以及bunx命令,并验证此命令能正确执行。
47-47: 新增依赖项:@rc-component/tree
此依赖"@rc-component/tree": "~1.0.0"与组件库调整相关,请确认其与现有代码库中其他模块的集成和兼容性。
49-49: 确认 classnames 依赖版本更新
将classnames更新到"^2.3.1"版本,请核实新版本是否与项目中其他依赖的版本及使用方式保持一致,避免潜在的版本冲突。
| "@types/react": "^19.0.0", | ||
| "@types/react-dom": "^19.0.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.
React 类型定义版本升级与 React 版本不匹配
@types/react 和 @types/react-dom 已升级到 ^19.0.0,但项目中 react 和 react-dom 依旧为 ^16.0.0。这种不一致可能导致类型错误或运行时问题。建议同步更新 react 和 react-dom 至兼容的新版,或验证当前组合能否正常工作。
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
🧹 Nitpick comments (1)
src/utils/treeUtil.ts (1)
29-30: 类型转换的添加提高了类型安全性为
child.key和parent.key添加as LegacyKey类型转换确保了与 valueSet 进行比较时的类型一致性,这是一个很好的改进。但是,根据静态分析工具的建议,可以考虑使用可选链来提高代码的健壮性。
- ? !(children && children.some(child => child.key && valueSet.has(child.key as LegacyKey))) + ? !(children?.some(child => child.key && valueSet.has(child.key as LegacyKey)))🧰 Tools
🪛 Biome (1.9.4)
[error] 29-29: Change to an optional chain.
Unsafe fix: Change to an optional chain.
(lint/complexity/useOptionalChain)
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
src/hooks/useSelect.ts(3 hunks)src/hooks/useValues.ts(2 hunks)src/utils/treeUtil.ts(2 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
- src/hooks/useValues.ts
- src/hooks/useSelect.ts
🧰 Additional context used
🪛 Biome (1.9.4)
src/utils/treeUtil.ts
[error] 29-29: Change to an optional chain.
Unsafe fix: Change to an optional chain.
(lint/complexity/useOptionalChain)
⏰ Context from checks skipped due to timeout of 90000ms (1)
- GitHub Check: test / react component workflow
🔇 Additional comments (2)
src/utils/treeUtil.ts (2)
6-6: 添加 LegacyKey 类型导入是合适的这个改动与整个 PR 中的类型重构保持一致,确保了类型系统的统一性。
12-12: 参数类型从 React.Key[] 更改为 LegacyKey[] 是合理的此更改与 PR 中将属性从 "dropdown" 重命名为 "popup" 的目标一致,同时统一了键类型的使用方式。
Summary by CodeRabbit