-
Notifications
You must be signed in to change notification settings - Fork 331
fix(grid): [grid] fix scrollLeft error after header drag resize #3087
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
Conversation
WalkthroughThe changes modify the Changes
Sequence Diagram(s)sequenceDiagram
participant U as User
participant H as documentOnmouseup Handler
participant T as $table.recalculate()
participant Header as Header element
participant Body as Body element
participant Footer as Footer element
U->>H: Mouseup event
H->>T: Call recalculate() asynchronously
T-->>H: Recalculation complete
H->>Header: Check for existence
H->>Body: Set scrollLeft = Header.scrollLeft (if exists)
H->>Footer: Set scrollLeft = Header.scrollLeft (if exists)
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
packages/vue/src/grid/src/header/src/header.tsOops! Something went wrong! :( ESLint: 8.57.1 ESLint couldn't find the plugin "eslint-plugin-vue". (The package "eslint-plugin-vue" was not found when loaded as a Node module from the directory "".) It's likely that the plugin isn't installed correctly. Try reinstalling by running the following: The plugin "eslint-plugin-vue" was referenced from the config file in ".eslintrc.js » @antfu/eslint-config » @antfu/eslint-config-vue". If you still can't figure out the problem, please stop by https://eslint.org/chat/help to chat with the team. ✨ Finishing Touches
🪧 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 (
|
WalkthroughThis pull request addresses an issue with the grid component where the Changes
|
| return | ||
| } | ||
| if (bodyElm) { | ||
| bodyElm.scrollLeft = headerElm.scrollLeft |
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.
Ensure that bodyElm and footerElm are not null before accessing scrollLeft. This prevents potential runtime errors if these elements are not present.
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.
Actionable comments posted: 0
🧹 Nitpick comments (1)
packages/vue/src/grid/src/header/src/header.ts (1)
414-439: Good implementation of async recalculation and scroll synchronization.The asynchronous handling of the recalculation process is a solid approach that ensures proper synchronization of scrollLeft between header, body, and footer elements after resizing. The code correctly uses optional chaining and conditionals to safely access elements before setting their scrollLeft values.
One suggestion:
Consider adding error handling for the Promise rejection case:
$table.recalculate().then(() => { // Implementation details... + }) + .catch((error) => { + console.error('Failed to recalculate table dimensions:', error) })
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
packages/vue/src/grid/src/header/src/header.ts(1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
- GitHub Check: PR E2E Test (pnpm test:e2e3)
PR
PR Checklist
Please check if your PR fulfills the following requirements:
PR Type
What kind of change does this PR introduce?
What is the current behavior?
Issue Number: N/A
What is the new behavior?
Does this PR introduce a breaking change?
Other information
Summary by CodeRabbit