-
-
Notifications
You must be signed in to change notification settings - Fork 606
fix: table forceScroll setTimeout issue #1259
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
base: master
Are you sure you want to change the base?
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
Walkthrough本次更改主要针对 Changes
Suggested reviewers
Poem
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 ESLint
src/Table.tsxOops! Something went wrong! :( ESLint: 8.57.1 ESLint couldn't find the config "prettier" to extend from. Please check that the name of the config is correct. The config "prettier" was referenced from the config file in "/.eslintrc.js". If you still have problems, please stop by https://eslint.org/chat/help to chat with the team. Tip ⚡💬 Agentic Chat (Pro Plan, General Availability)
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
🔇 Additional comments (1)
✨ Finishing Touches
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
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)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR addresses a bug in the forceScroll method where rapid consecutive calls could lead to a race condition, causing the table header and body to become misaligned.
- Updated the forceScroll function to include a union type for the target parameter that supports an optional _scrollTimeout property.
- Added logic to clear existing scheduled timeouts before scheduling a new one, ensuring the scrollLeft assignment reflects the latest call.
@@ -426,11 +426,17 @@ function Table<RecordType extends DefaultRecordType>( | |||
} else if (target.scrollLeft !== scrollLeft) { | |||
target.scrollLeft = scrollLeft; | |||
|
|||
if (target._scrollTimeout) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When the target parameter is a function, accessing the _scrollTimeout property may cause issues since functions do not have this property. Consider adding a type guard to ensure that target is an HTMLDivElement instance before checking _scrollTimeout.
if (target._scrollTimeout) { | |
if (target instanceof HTMLDivElement && target._scrollTimeout) { |
Copilot uses AI. Check for mistakes.
f修复 forceScroll 方法中当 setTimeout 调用不是最后一次时机时,有可能会出现最后一次的 target.scrollLeft 赋值操作被后续setTimeout中的 target.scrollLeft 赋值给覆盖,由此一来造成表头和表体错位的问题。
Summary by CodeRabbit