Repository navigation
fix: distinguish numeric and string notification keys - #422
mokshupadhyay wants to merge 1 commit into
Conversation
|
@mokshupadhyay is attempting to deploy a commit to the afc163's projects Team on Vercel. A member of the Team first needs to authorize it. |
|
No actionable comments were generated in the recent review. Walkthrough通知键现在包含键类型和键值。通知列表使用该键进行索引查找、渲染、尺寸注册和偏移查询。新增测试验证数字键 Changes通知键类型区分
Estimated code review effort: 2 (Simple) | ~12 minutes Change: Bug fix Suggested reviewers: Merge Risk:
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #422 +/- ##
=======================================
Coverage 99.21% 99.22%
=======================================
Files 12 12
Lines 383 385 +2
Branches 103 103
=======================================
+ Hits 380 382 +2
Misses 3 3 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
Hi @yoyo837, a friendly ping: this is ready for review whenever you have time. Happy to adjust anything. Thanks! |
Notices are tracked by key in several places (
NotificationList,getIndex, anduseListPosition, which stores sizes and offsets), and each of them converts the key withString(key). A numeric key1and a string key'1'are valid, different keys (open/closecompare them strictly), but they end up with the same entry in those maps. The two notices then get the same index and the same stacking offset, so they are laid out as one.Real result of the new test (two notices opened with
key: 1andkey: '1',offsetHeightmocked to 50), from the original source:data-notification-indexof the two notices['1', '1']['1', '0']and--notification-yof50pxand0pxThe fix adds one helper,
getNoticeKey(key)(${typeof key}-${key}), inuseListPositionand uses it everywhere the string form of the key was used, including the Reactkeyof the list item. After closing1, only the'1'notice remains.Tests: added
distinguishes numeric and string keys with the same string representationintests/hooks.test.tsx; it fails on the original source and passes now.vitest runpasses (6 files, 66 tests),npm run tscis clean, andnpm run lintreports 0 errors (10 warnings; I did not compare the warning count with the base branch). Open PR #409 editssrc/Notification.tsx src/hooks/useNoticeTimer.ts tests/index.test.tsx tests/useNoticeTimer.test.tsx, which are different files from the ones changed here.Summary by CodeRabbit