Closed hanszeng-chn closed 4 weeks ago
The latest updates on your projects. Learn more about Vercel for Git ↗︎
Name | Status | Preview | Comments | Updated (UTC) |
---|---|---|---|---|
virtual-list | ✅ Ready (Inspect) | Visit Preview | 💬 Add feedback | Sep 20, 2024 2:34am |
此更改主要集中在 src/List.tsx
中对 RawList
函数的修改,以增强 Firefox 浏览器中的鼠标滚动事件处理。通过引入 isScrollAtTop
和 isScrollAtBottom
标志,改善了在列表顶部和底部的滚动限制检查。此外,tests/scroll-Firefox.test.js
中增加了三个新的测试用例,以验证在 Firefox 环境中处理 MozMousePixelScroll
事件的行为。
文件 | 更改摘要 |
---|---|
src/List.tsx | 修改 RawList 函数以改进 Firefox 中的鼠标滚动事件处理,增加滚动限制检查。更新 useLayoutEffect 的依赖数组。 |
tests/scroll-Firefox.test.js | 添加三个新测试用例,验证 Firefox 中的 MozMousePixelScroll 事件行为。 |
Objective | Addressed | Explanation |
---|---|---|
解决 Firefox 中虚拟表格无法注册页面滚动的问题 (#49399) | ✅ |
在兔子乐园,滚动如风,
Firefox 中的表格,快来相逢。
鼠标轻触,页面随之动,
测试覆盖,问题不再重。
代码更新,欢声笑语,
兔子跳跃,庆祝这美好时光! 🐰✨
tests/scroll-Firefox.test.js (3)
`88-103`: **测试用例没有问题!** 这个测试用例验证了当触发 `MozMousePixelScroll` 事件并且 `detail` 值为正数时,`preventDefault` 方法会被调用。这确保了列表组件能正确处理向下滚动的情况,阻止默认的滚动行为。 --- `105-120`: **测试用例没有问题!** 这个测试用例验证了当在列表顶部触发 `MozMousePixelScroll` 事件并且 `detail` 值为负数时,`preventDefault` 方法不会被调用。这确保了列表组件能正确处理在顶部边界尝试向上滚动的情况,允许默认的滚动行为。 --- `121-141`: **测试用例没有问题!** 这个测试用例验证了当在列表底部触发 `MozMousePixelScroll` 事件并且 `detail` 值为正数时,`preventDefault` 方法不会被调用。这确保了列表组件能正确处理在底部边界尝试向下滚动的情况,允许默认的滚动行为。src/List.tsx (1)
Line range hint `428-447`: **改进了 Firefox 中的滚动事件处理。** 这些更改通过引入 `isScrollAtTop` 和 `isScrollAtBottom` 标志,增强了 Firefox 中的鼠标滚动事件处理。现在,当列表已经在顶部或底部时,`onMozMousePixelScroll` 事件处理程序会检查用户是否正在尝试向上或向下滚动。如果滚动在这些限制范围内,则仅在 `useVirtual` 为 true 时才会阻止默认的滚动行为。 此外,`useLayoutEffect` 的依赖数组已更新,包括 `isScrollAtTop` 和 `isScrollAtBottom`。这确保了滚动处理逻辑会在这些状态发生变化时重新运行,从而提高了滚动处理的响应性。 这些改进增强了 Firefox 中的用户体验,允许在列表位于顶部或底部时文档仍然可以滚动。
@zombieJ Can you help review my pr pls?
All modified and coverable lines are covered by tests :white_check_mark:
Project coverage is 98.45%. Comparing base (
02dfd34
) to head (2c1b552
). Report is 5 commits behind head on master.
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
+ rc-virtual-list@3.14.8
🤔 This is a ...
🔗 Related Issues
💡 Background and Solution
Summary by CodeRabbit
新特性
测试