Skip to content

Conversation

gimmyhehe
Copy link
Member

@gimmyhehe gimmyhehe commented Jan 22, 2025

PR

修复横向虚拟滚动场景下,表尾渲染不正常问题。
修复前:
image
修复后:
image

PR Checklist

Please check if your PR fulfills the following requirements:

  • The commit message follows our Commit Message Guidelines
  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been added / updated (for bug fixes / features)

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Documentation content changes
  • Other... Please describe:

What is the current behavior?

Issue Number: N/A

What is the new behavior?

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

Summary by CodeRabbit

  • Version Update

    • Updated @opentiny/vue-grid package version from 3.21.1 to 3.21.2
  • Performance Improvements

    • Enhanced scroll synchronization in grid component
    • Optimized table rendering and style update logic
    • Improved footer layout management
  • Technical Refinements

    • Streamlined event handling in grid body component
    • Adjusted asynchronous rendering methods
    • Introduced more precise element management for layout
  • Test Updates

    • Modified visibility assertions in grid editor test cases for improved accuracy

Copy link

coderabbitai bot commented Jan 22, 2025

Walkthrough

This pull request focuses on updating the @opentiny/vue-grid package, involving modifications to several files in the grid component. The changes primarily affect scroll synchronization, layout handling, and version management. The package version has been incremented from 3.21.1 to 3.21.2, with updates to the body scroll handling, table method updates, and style utility functions to improve element management and rendering logic.

Changes

File Change Summary
packages/vue/src/grid/package.json Version updated from 3.21.1 to 3.21.2
packages/vue/src/grid/src/body/src/body.tsx - Refactored syncHeaderAndFooterScroll to use local scrollLeft variable
- Updated render method to include scroll event listener directly in on object
packages/vue/src/grid/src/table/src/methods.ts Modified updateScrollXData to use $nextTick with explicit updateFooter() and updateStyle() calls
packages/vue/src/grid/src/table/src/utils/updateStyle.ts Added elemStore parameter to layoutFooter and handleLayout functions for improved element management
examples/sites/demos/pc/app/grid/editor/custom-edit.spec.js Updated visibility assertions for textboxes to check specific cell names instead of row names

Suggested reviewers

  • zzcr

Poem

🐰 Hop, hop, through the grid we go,
Scrolling smooth, version's new glow
Elements dance with grace and might
Vue's magic renders just right!
A rabbit's code, both clean and bright 🌟

✨ Finishing Touches
  • 📝 Generate Docstrings (Beta)

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ 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.
    • Generate unit testing code for this file.
    • 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 generate unit testing code for this file.
    • @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 generate unit testing code.
    • @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.

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. (Beta)
  • @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 the bug Something isn't working label Jan 22, 2025
Copy link

Walkthrough

此PR修复了横向虚拟滚动场景下表尾渲染不正常的问题。主要通过同步表头和表尾的滚动位置,并在表尾设置虚拟滚动占位宽度来解决。

Changes

文件 概要
packages/vue/src/grid/src/body/src/body.tsx 修复了表头和表尾的滚动同步问题,移除了不必要的滚动事件监听,并添加了新的滚动事件处理。
packages/vue/src/grid/src/table/src/methods.ts 更新了表格渲染逻辑,确保在更新样式之前更新表尾。
packages/vue/src/grid/src/table/src/utils/updateStyle.ts 添加了为表尾设置虚拟滚动占位宽度的逻辑。
packages/vue/src/grid/package.json 版本号或依赖项的微小调整。

@@ -751,11 +751,12 @@ function renderDefEmpty(h) {
}

const syncHeaderAndFooterScroll = ({ bodyElem, footerElem, headerElem, isX }) => {

Choose a reason for hiding this comment

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

The variable scrollLeft is introduced to store bodyElem.scrollLeft, which is then used to set headerElem.scrollLeft and footerElem.scrollLeft. This change ensures that the scroll position is consistent across header and footer, which is crucial for visual alignment.


this.$nextTick(this.updateStyle)
this.$nextTick(() => {
this.updateFooter()

Choose a reason for hiding this comment

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

The update to call updateFooter() before updateStyle() ensures that the footer is correctly rendered before any style updates, which is important for maintaining layout integrity.

@@ -61,6 +62,11 @@ function layoutFooter({
let tWidth = tableWidth
// 如果是固定列与设置了超出隐藏
let ret = getTableWidth({ scrollXLoad, tWidth, tableColumn })
// 为表尾设置虚拟滚动占位宽度
const spaceElem = elemStore['main-footer-x-space']

Choose a reason for hiding this comment

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

Adding a virtual scroll placeholder width for the footer helps in maintaining the correct layout when horizontal scrolling is involved. This ensures that the footer aligns properly with the table content.

@Issues-translate-bot
Copy link

Bot detected the issue body's language is not English, translate it automatically.


Walkthrough

This PR fixes the problem of abnormal rendering of the end of the table in horizontal virtual scrolling scenarios. This is mainly solved by synchronizing the scrolling positions of the table header and table footer, and setting the virtual scrolling occupancy width at the table footer.

Changes

Documentation Summary
packages/vue/src/grid/src/body/src/body.tsx Fixed the scroll synchronization problem of table header and table footer, removed unnecessary scroll event listening, and added new scroll event processing.
packages/vue/src/grid/src/table/src/methods.ts Updated table rendering logic to ensure the table footer is updated before updating the style.
packages/vue/src/grid/src/table/src/utils/updateStyle.ts Added logic to set virtual scroll spacer width for table footer.
packages/vue/src/grid/package.json Minor adjustments to version numbers or dependencies.

@gimmyhehe gimmyhehe linked an issue Jan 22, 2025 that may be closed by this pull request
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: 0

🧹 Nitpick comments (1)
examples/sites/demos/pc/app/grid/editor/custom-edit.spec.js (1)

Line range hint 1-9: Consider adding tests for footer functionality.

Since this PR fixes a footer bug in the visual scroll scene, it would be beneficial to add test coverage for this specific functionality to prevent regressions.

Would you like me to help generate test cases that verify the footer's behavior during horizontal virtual scrolling?

Consider translating the test name for consistency.

The test name "多行编辑" (multi-line editing) could be translated to English for better maintainability across international teams.

-test('多行编辑', async ({ page }) => {
+test('Multi-line editing', async ({ page }) => {
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between b2bdada and 99fb173.

📒 Files selected for processing (1)
  • examples/sites/demos/pc/app/grid/editor/custom-edit.spec.js (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: PR E2E Test (pnpm test:e2e3)
🔇 Additional comments (1)
examples/sites/demos/pc/app/grid/editor/custom-edit.spec.js (1)

6-7: LGTM! Improved element targeting strategy.

The change from row-based to cell-based targeting is a good improvement that makes the tests more precise and maintainable.

@zzcr zzcr merged commit b5855ee into release-3.21.0 Jan 22, 2025
9 of 10 checks passed
kagol pushed a commit that referenced this pull request Feb 8, 2025
* fix: [grid] fix footer bug in visual scroll scene

* test: fix e2e test case
kagol pushed a commit that referenced this pull request Feb 8, 2025
* fix: [grid] fix footer bug in visual scroll scene

* test: fix e2e test case
@kagol kagol deleted the cgm/grid-footer-fix branch April 14, 2025 12:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

🐛 [Bug]: TinyGrid的表尾在列多时显示异常
3 participants