nutui-react icon indicating copy to clipboard operation
nutui-react copied to clipboard

修复Cascader动态加载层级不存在报错导致不显示内容的问题,及Popup关闭按钮点穿的问题

Open clayzx opened this issue 5 months ago • 2 comments

🤔 这个变动的性质是?

  • [ ] 新特性提交
  • [ ] 日常 bug 修复
  • [ ] 站点、文档改进
  • [ ] 演示代码改进
  • [ ] 组件样式/交互改进
  • [ ] TypeScript 定义更新
  • [ ] 包体积优化
  • [ ] 性能优化
  • [ ] 功能增强
  • [ ] 国际化改进
  • [ ] 重构
  • [ ] 代码风格优化
  • [ ] 测试用例
  • [ ] 分支合并
  • [ ] 其他改动(是关于什么的改动?)

🔗 相关 Issue

💡 需求背景和解决方案

☑️ 请求合并前的自查清单

⚠️ 请自检并全部勾选全部选项。⚠️

  • [ ] 文档已补充或无须补充
  • [ ] 代码演示已提供或无须提供
  • [ ] TypeScript 定义已补充或无须补充
  • [ ] fork仓库代码是否为最新避免文件冲突
  • [ ] Files changed 没有 package.json lock 等无关文件

Summary by CodeRabbit

  • Bug Fixes
    • 级联选择:修复懒加载过程中父节点未就绪导致的报错与选项渲染异常,提升稳定性与加载可靠性。
    • 弹窗:修复点击关闭图标会冒泡触发上层点击事件的问题,避免误触导致的意外关闭或重复回调,使交互更一致。

clayzx avatar Sep 04 '25 12:09 clayzx

Walkthrough

对 Cascader 懒加载链式归并中对子节点赋值增加了父节点空值保护;对 Popup 的关闭图标点击事件添加了 stopPropagation,避免冒泡影响其他点击逻辑。对外导出未变更。

Changes

Cohort / File(s) Summary
Cascader 懒加载空值保护
src/packages/cascader/cascader.taro.tsx
在 reduce 流程中为 parent.children = pane 增加判空:改为 if (parent) parent.children = pane,避免 parent 未定义时报错;其余逻辑保持不变。
Popup 关闭图标点击处理
src/packages/popup/popup.taro.tsx
handleCloseIconClick 中加入 e.stopPropagation(),防止点击关闭图标触发外层(如遮罩)点击处理;后续仍执行 onCloseIconClick(e) && close()

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor U as 用户
  participant CI as CloseIcon(关闭图标)
  participant PH as Popup(容器/遮罩)
  participant H as 处理器

  U->>CI: click
  note right of CI: 新增:stopPropagation()
  CI->>H: onCloseIconClick(e)
  alt 返回真
    H->>PH: close()
  else 返回假
    H-->>U: 不关闭
  end

  U->>PH: click(遮罩)
  PH->>PH: overlay onClick
  PH->>PH: close()
sequenceDiagram
  autonumber
  participant C as Cascader
  participant R as reduce(懒加载链)
  participant P as parent(可能为undefined)
  participant N as pane(子节点)

  C->>R: 迭代构建层级
  R->>P: 取得当前父节点
  alt P 存在
    R->>P: P.children = N
  else P 不存在
    note right of R: 新增空值保护:跳过赋值
  end
  R-->>C: 返回最终 options
  C->>C: setInnerOptions(...)

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

  • jdf2e/nutui-react#2944 — 同触达点:修改 src/packages/popup/popup.taro.tsx 的关闭图标点击处理(该 PR对处理器进行重命名与简化),与本次添加 stopPropagation() 的变更紧密相关。

Suggested reviewers

  • oasis-cloud
  • irisSong
  • xiaoyatong

Poem

小兔拍耳听风声,
级级懒载护父根。
关窗一按不外传,
泡泡静落夜色深。
代码轻拢无惊雷,
行间稳当赴清晨。

✨ Finishing Touches
  • [ ] 📝 Generate Docstrings
🧪 Generate unit tests
  • [ ] Create PR with unit tests
  • [ ] Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore or @coderabbit ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

coderabbitai[bot] avatar Sep 04 '25 12:09 coderabbitai[bot]

Codecov Report

:white_check_mark: All modified and coverable lines are covered by tests. :white_check_mark: Project coverage is 88.15%. Comparing base (52d84bd) to head (7ddeab9).

Additional details and impacted files
@@            Coverage Diff             @@
##           feat_v3.x    #3354   +/-   ##
==========================================
  Coverage      88.15%   88.15%           
==========================================
  Files            291      291           
  Lines          19212    19212           
  Branches        2988     2988           
==========================================
  Hits           16937    16937           
  Misses          2269     2269           
  Partials           6        6           

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

:rocket: New features to boost your workflow:
  • :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • :package: JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

codecov[bot] avatar Sep 04 '25 12:09 codecov[bot]