Skip to content
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

fix:doesn't scroll when use scrollTo with top zero #1180

Merged
merged 4 commits into from
Aug 23, 2024

Conversation

IsKaros
Copy link
Contributor

@IsKaros IsKaros commented Aug 23, 2024

Copy link

vercel bot commented Aug 23, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
table ✅ Ready (Inspect) Visit Preview 💬 Add feedback Aug 23, 2024 10:30am

src/Table.tsx Outdated Show resolved Hide resolved
@afc163
Copy link
Member

afc163 commented Aug 23, 2024

补一个测试用例。

Copy link

codecov bot commented Aug 23, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 97.70%. Comparing base (aa8a75e) to head (6cf22da).
Report is 2 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #1180   +/-   ##
=======================================
  Coverage   97.70%   97.70%           
=======================================
  Files          75       75           
  Lines        7402     7416   +14     
  Branches     1109     1110    +1     
=======================================
+ Hits         7232     7246   +14     
  Misses        164      164           
  Partials        6        6           

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

@afc163 afc163 merged commit 8b02e79 into react-component:master Aug 23, 2024
8 checks passed
@@ -332,7 +332,8 @@ function Table<RecordType extends DefaultRecordType>(
// Native scroll
const { index, top, key } = config;

if (top) {
// * 考虑top为0的情况
if (top || top === 0) {
Copy link
Member

@li-jia-nan li-jia-nan Aug 24, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

逻辑不太清晰,不能依靠注释来解释逻辑,我的建议是写一个方法判断:

function isVerifyValue(value: any) {
  return typeof value === "number" && !Number.isNaN(value);
}

if (isValidValue(top)) {
  scrollBodyRef.current?.scrollTo({ top });
}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

3 participants