Skip to content

fix: trigger leave when hovered notifications unmount - #415

Merged
zombieJ merged 2 commits into
masterfrom
codex/notification-destroy-hover
Sep 29, 2026
Merged

zombieJ merged 2 commits into
masterfrom
codex/notification-destroy-hover

Conversation

@zombieJ

@zombieJ zombieJ commented Sep 29, 2026 •

Copy link
Copy Markdown
Member

变更

Notification 在悬停状态下卸载时,通过 effect 清理调用自身的 leave 逻辑。卸载回调没有鼠标事件,因此 onMouseLeave 的 event 参数可省略。未悬停或已经离开的卡片不重复触发 leave。

List 继续依靠自身的 enter/leave 更新悬停状态,卡片卸载不强制清空 List hover,避免补位卡片仍覆盖鼠标时错误收起。

Closes #413
Closes #383
Fixes ant-design/ant-design#59412

Related: #414、ant-design/ant-design#57096(均已关闭)。

验证

  • 55 个单测通过,覆盖悬停卸载、未悬停卸载及离开后卸载。
  • TypeScript 和改动文件 ESLint 检查通过。
  • 本地 stack 示例验证:关闭倒数第二张,鼠标留在补位区域,剩余四张保持展开;移出 List 后正常收起。
  • 删除末尾卡片后保持展开的现象已核实:示例外层 List 高度为 100vh,展开时 pointer-events 为 auto,鼠标仍在 List 内,原生 :hover 为 true;这不属于遗漏 leave。
  • stack 示例设置 duration: false,本次浏览器验证未覆盖自动关闭计时,也未完整复测 antd issue 的运行环境。

Summary by CodeRabbit

  • 修复
    • 通知悬停时卸载组件,会正确恢复悬停状态并继续计时;未悬停或已离开时不会触发多余的离开回调。
    • 离开回调现在可接收可选的鼠标事件。

@vercel

vercel Bot commented Sep 29, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
notification Ready Ready Preview Sep 29, 2026 4:02am UTC

@coderabbitai

coderabbitai Bot commented Sep 29, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Advanced

Run ID: 5a8b309a-85d8-4288-83b1-7b073dc9410d

📥 Commits

Reviewing files that changed from the base of the PR and between dd2ba0b and 5ca2b89.

📒 Files selected for processing (2)
  • src/Notification.tsx
  • tests/notification-unmount.test.tsx

Included review availability: This review used your included allowance. Your plan provides up to 2 included reviews per hour; 1 remain after this review.


Walkthrough

通知组件在卸载时,如果仍处于悬停状态,则执行鼠标离开处理。该处理会重置悬停状态,并按现有条件恢复计时器。onMouseLeave 现在允许不传鼠标事件。

Changes

通知悬停清理

Layer / File(s) Summary
可选事件与卸载清理
src/Notification.tsx, tests/notification-unmount.test.tsx
onMouseLeave 和内部鼠标离开处理函数接受可选事件。通知在仍处于悬停状态时卸载,会调用内部处理函数。测试覆盖从未悬停、仍在悬停和已经离开的状态。

Priority: ➖ Normal

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix · Severity of issue fixed: Medium

Merge Risk: ⚪ Minimal · up to 5ca2b

The changed unmount behavior has no identified merge-blocking issue. Automatic-close timing still warrants normal browser validation.

Security Architecture Review

Security architecture risk: 🔵 Low · up to 5ca2b

The change may affect applications whose mouse-leave handlers require an event. No new security authority or sensitive operation was identified in the notification cleanup path, but downstream handler behavior remains uncertain.

Retained concerns

  • Low · architecture · inferred: A consumer that requires a mouse event may fail when a hovered notification invokes onMouseLeave during unmount with undefined. This changes the public callback contract; no affected downstream consumer was identified.
Security review details

Security Blast Radius

  • inferred — The directly visible effect is limited to a notification's hover and timer handling plus its configured callback. Downstream callback implementations were not established, so their effects cannot be bounded here.

Trust Boundaries and Controls

  • observed — Notification invokes an application-supplied callback after its internal leave handling. Unmount adds a call without a DOM event; it does not directly invoke the list's separate leave handler.
🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Linked Issues check ⚠️ Warning 未满足直接关联问题的核心编码要求。[#413] 本次仅在 Notification.tsx 卸载时调用本地 onInternalMouseLeave。NotificationList/index.tsx 的 listHovering 不会因通知卸载而更新,也没有实现问题要求的列表移动路径、:hover 回退或 Shadow DOM 场景恢复。[#383] 没有证明剩余通知在移除… 在 NotificationList 层实现通知列表状态的卸载后恢复。列表仍被悬停时保持展开并暂停计时;确认指针已移出列表时清除 listHovering,使剩余通知收起并恢复剩余倒计时。按 #413 的要求覆盖文档事件路径、闭合 Shadow DOM 的原生 :hover 回退及相关回归测试。补充 #383 和 #59412 的堆叠列表集成测试,包括超过阈值和剩余时长场景。
Docstring Coverage ⚠️ Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 3 functions across 2 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Out of Scope Changes check ✅ Passed 变更集中在通知卸载时的 hover 清理、计时恢复和对应单元测试。公共回调参数允许缺少鼠标事件,以支持卸载路径。上述变更均与 [#413]、[#383] 和 [#59412] 的通知 hover、堆叠和自动关闭目标直接相关。未发现无关功能或无关文件变更。
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed 标题准确概括了主要变更:当处于悬停状态的通知卸载时触发离开逻辑。标题简洁、明确,并与代码和测试变更一致。
Full details: Linked Issues check

Explanation

未满足直接关联问题的核心编码要求。[#413] 本次仅在 Notification.tsx 卸载时调用本地 onInternalMouseLeave。NotificationList/index.tsx 的 listHovering 不会因通知卸载而更新,也没有实现问题要求的列表移动路径、:hover 回退或 Shadow DOM 场景恢复。[#383] 没有证明剩余通知在移除悬停通知后、指针移出列表时恢复倒计时。[#59412] 堆叠模式下剩余通知仍可能收到 hovering={true};卸载清理在 forcedHovering 为真时不会调用 onResume,因此不能保证收起堆叠并恢复自动关闭。新增测试只覆盖单个 Notification 的卸载回调,没有覆盖列表、堆叠阈值、倒计时或指针移出场景。

  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR

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

我是小兔,轻轻掠过通知旁,
卸载时若仍悬停,离开处理会登场。
事件可以缺席,状态照常归位,
计时依照条件,再次开始奔跑。
三种状态都已测试,月光下安睡。

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

@github-actions

github-actions Bot commented Sep 29, 2026 •

Copy link
Copy Markdown

React Doctor found 1 new issue in 1 file · 1 warning · score 70 / 100 (Needs work) · 1 fixed · vs master

1 warning

src/Notification.tsx

  • ⚠️ L73 React function has high control-flow complexity no-high-complexity-react-function

Reviewed by React Doctor for commit 5ca2b89. See inline comments for fixes.

@codecov

codecov Bot commented Sep 29, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.21%. Comparing base (dd2ba0b) to head (5ca2b89).

Additional details and impacted files
@@           Coverage Diff           @@
##           master     #415   +/-   ##
=======================================
  Coverage   99.20%   99.21%           
=======================================
  Files          12       12           
  Lines         376      380    +4     
  Branches      102      103    +1     
=======================================
+ Hits          373      377    +4     
  Misses          3        3           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

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

@github-actions

github-actions Bot commented Sep 29, 2026 •

Copy link
Copy Markdown

❌ Deploy failed

PR preview ❌ Failed ❌ Failed
🔗 Preview https://react-component-notification-preview-pr-415.surge.sh (may be unavailable)
📝 Commit5ca2b89
🪵 LogsView logs
📋 Build log (last lines)
npm error     @eslint-community/eslint-utils@"^4.9.1" from @typescript-eslint/utils@8.71.0
npm error     node_modules/@typescript-eslint/utils
npm error       @typescript-eslint/utils@"8.71.0" from @typescript-eslint/eslint-plugin@8.71.0
npm error       node_modules/@typescript-eslint/eslint-plugin
npm error         peerOptional @typescript-eslint/eslint-plugin@"^8.0.0" from eslint-plugin-jest@29.16.6
npm error         node_modules/eslint-plugin-jest
npm error         1 more (typescript-eslint)
npm error       3 more (@typescript-eslint/type-utils, eslint-plugin-jest, typescript-eslint)
npm error     @eslint-community/eslint-utils@"^4.8.0" from eslint@10.11.0
npm error   10 more (@eslint/compat, @eslint/js, ...)
npm error
npm error Could not resolve dependency:
npm error peer eslint@"^3 || ^4 || ^5 || ^6 || ^7 || ^8 || ^9.7" from eslint-plugin-react@7.37.5
npm error node_modules/eslint-plugin-react
npm error   dev eslint-plugin-react@"^7.37.5" from the root project
npm error
npm error Conflicting peer dependency: eslint@9.39.5
npm error node_modules/eslint
npm error   peer eslint@"^3 || ^4 || ^5 || ^6 || ^7 || ^8 || ^9.7" from eslint-plugin-react@7.37.5
npm error   node_modules/eslint-plugin-react
npm error     dev eslint-plugin-react@"^7.37.5" from the root project
npm error
npm error Fix the upstream dependency conflict, or retry
npm error this command with --force or --legacy-peer-deps
npm error to accept an incorrect (and potentially broken) dependency resolution.
npm error
npm error
npm error For a full report see:
npm error /home/runner/.npm/_logs/2026-09-29T04_02_41_579Z-eresolve-report.txt
npm error A complete log of this run can be found in: /home/runner/.npm/_logs/2026-09-29T04_02_41_579Z-debug-0.log

🤖 Powered by surge-preview

@zombieJ zombieJ changed the title fix: reset stack hover when hovered notifications are destroyed fix: trigger leave when hovered notifications unmount Sep 29, 2026
@zombieJ
zombieJ marked this pull request as ready for review September 29, 2026 06:23
@zombieJ zombieJ changed the title fix: trigger leave when hovered notifications unmount [WIP]fix: trigger leave when hovered notifications unmount Sep 29, 2026
@zombieJ zombieJ changed the title [WIP]fix: trigger leave when hovered notifications unmount fix: trigger leave when hovered notifications unmount Sep 29, 2026
@zombieJ
zombieJ merged commit 467687c into master Sep 29, 2026
16 checks passed
@zombieJ
zombieJ deleted the codex/notification-destroy-hover branch September 29, 2026 06:49

This branch was successfully deployed

1 active deployment
Preview – notification — 5ca2b892 Deployed Sep 29, 2026 by vercel[bot]
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.

点击 Notification 关闭按钮后,通知未关闭且保持 hover 展开状态

1 participant