Skip to content

fix(noticebar): first item is not visible when scrolling vertically #3249

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

Open
wants to merge 1 commit into
base: feat_v3.x
Choose a base branch
from

Conversation

mingquan5830
Copy link

@mingquan5830 mingquan5830 commented Jun 3, 2025

🤔 这个变动的性质是?

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

🔗 相关 Issue

#1893

💡 需求背景和解决方案

复现步骤:
官方文档的Demo中即可复现:NoticeBar 纵向模式:自定义滚动内容
解决方案:

  1. 问题原因
    image

代码中实现无限轮播是通过垂直偏移容器与第一项内容来实现的,但是这里忽略了一个点:当偏移第一项时,其实它已经不在容器中了,虽然在整个视图中它的位置是对的,但并不可见。

  1. 解决方法
    image

可以给容器加一列高度来处理第一项的偏移

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

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

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

Summary by CodeRabbit

  • Bug Fixes
    • 优化了公告栏垂直滚动容器的高度计算,提升了滚动的流畅性和视觉连续性。
  • Tests
    • 新增公告栏垂直滚动容器高度计算的测试用例,确保样式应用准确。

Copy link

coderabbitai bot commented Jun 3, 2025

Walkthrough

本次更改调整了 NoticeBar 组件中垂直滚动容器的高度计算方式。原本高度为单项高度与子元素数量的乘积,现将高度增加一个单项高度,变为单项高度乘以(子元素数量加一),以支持更流畅的滚动效果。新增了对应的测试用例验证此高度计算。其他逻辑未作更改。

Changes

文件 变更摘要
src/packages/noticebar/noticebar.taro.tsx
src/packages/noticebar/noticebar.tsx
调整垂直滚动容器高度为 height * (childCount + 1),以便容纳额外元素,实现更平滑的滚动。
src/packages/noticebar/test/noticebar.spec.tsx 新增测试用例,验证垂直滚动容器高度计算包含额外一项高度。

Suggested reviewers

  • oasis-cloud
  • irisSong

Poem

小兔轻跳舞,代码添新意,
公告栏高一层,滚动更顺畅。
多加一份高,视觉更自然,
测试保驾护航,品质更安心。
🐇💻✨


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 61d266a and ce7517f.

📒 Files selected for processing (3)
  • src/packages/noticebar/__test__/noticebar.spec.tsx (1 hunks)
  • src/packages/noticebar/noticebar.taro.tsx (1 hunks)
  • src/packages/noticebar/noticebar.tsx (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • src/packages/noticebar/noticebar.tsx
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/packages/noticebar/noticebar.taro.tsx
🧰 Additional context used
🧬 Code Graph Analysis (1)
src/packages/noticebar/__test__/noticebar.spec.tsx (1)
src/packages/noticebar/noticebar.tsx (1)
  • NoticeBar (33-509)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: test
🔇 Additional comments (1)
src/packages/noticebar/__test__/noticebar.spec.tsx (1)

224-262: 测试用例很好地验证了容器高度计算修复

这个新增的测试用例有效地验证了垂直滚动容器高度计算的修复逻辑。测试正确地:

  1. 设置了4个子元素,每个高度50px
  2. 验证容器高度为 (子元素数量 + 1) * 高度 = (4 + 1) * 50 = 250px
  3. 使用合适的超时时间等待异步样式应用
  4. 包含清晰的中文注释说明计算逻辑

这个测试能够确保修复后的高度计算逻辑按预期工作,有助于防止将来的回归问题。

✨ Finishing Touches
  • 📝 Generate Docstrings

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.
    • Explain this complex logic.
    • 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. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • 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 src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

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

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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai 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

Documentation and Community

  • 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.

@github-actions github-actions bot added 3.x Target branch 3.x action:review This PR needs more reviews (less than 2 approvals) labels Jun 3, 2025
Copy link

codecov bot commented Jun 3, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 87.90%. Comparing base (2be2459) to head (ce7517f).

Additional details and impacted files
@@              Coverage Diff              @@
##           feat_v3.x    #3249      +/-   ##
=============================================
+ Coverage      87.59%   87.90%   +0.31%     
=============================================
  Files            290      290              
  Lines          19102    19102              
  Branches        2930     2950      +20     
=============================================
+ Hits           16732    16792      +60     
+ Misses          2365     2305      -60     
  Partials           5        5              

☔ View full report in Codecov by Sentry.
📢 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.

Copy link

@coderabbitai coderabbitai bot left a 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

📥 Commits

Reviewing files that changed from the base of the PR and between 2be2459 and 61d266a.

📒 Files selected for processing (2)
  • src/packages/noticebar/noticebar.taro.tsx (1 hunks)
  • src/packages/noticebar/noticebar.tsx (1 hunks)
🧰 Additional context used
🪛 GitHub Check: codecov/patch
src/packages/noticebar/noticebar.tsx

[warning] 356-356: src/packages/noticebar/noticebar.tsx#L356
Added line #L356 was not covered by tests

⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: test
  • GitHub Check: build
🔇 Additional comments (1)
src/packages/noticebar/noticebar.taro.tsx (1)

361-361: 与 React 版本保持一致的正确修复

Taro 版本的修改与 React 版本完全一致,确保了跨平台行为的统一性。高度计算的调整 (childCount + 1) 正确地为垂直无限滚动提供了额外的容器空间,解决了第一项在滚动过程中不可见的问题。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3.x Target branch 3.x action:review This PR needs more reviews (less than 2 approvals) size/M
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant