Skip to content

Conversation

@gimmyhehe
Copy link
Member

@gimmyhehe gimmyhehe commented Jan 13, 2025

PR

修复动态插入的分组表头设置左冻结后,left样式设置不正确的问题
修复前:
PixPin_2025-01-11_17-48-51

修复后:
PixPin_2025-01-11_17-47-30

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.0 to 3.21.1
  • Performance Improvements

    • Enhanced table column width handling logic
    • Optimized column style assignment process
    • Improved performance for column positioning and styling

@coderabbitai
Copy link

coderabbitai bot commented Jan 13, 2025

Walkthrough

This pull request involves a minor version update for the @opentiny/vue-grid package from version 3.21.0 to 3.21.1. The changes include modifications to the autoCellWidth.ts file, which enhances the logic for handling column widths in a table layout. The update introduces a new finishColumns Set to track processed columns and refines the column style assignment process to prevent redundant styling and improve efficiency.

Changes

File Change Summary
packages/vue/src/grid/package.json Version updated from 3.21.0 to 3.21.1
packages/vue/src/grid/src/table/src/utils/autoCellWidth.ts Improved column width handling logic with new finishColumns Set and refined style assignment process

Possibly related PRs

Suggested labels

bug

Suggested reviewers

  • zzcr

Poem

🐰 A grid so fine, with columns aligned,
Version bumped with care divine,
Styles refined, performance refined,
A rabbit's touch, code intertwined!
🚀 Efficiency's new design! 🌟

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.

@gimmyhehe gimmyhehe added the breaking change Breaking change(破坏性变更) label Jan 13, 2025
@github-actions github-actions bot added the bug Something isn't working label Jan 13, 2025
@gimmyhehe gimmyhehe removed the breaking change Breaking change(破坏性变更) label Jan 13, 2025
@petercat-assistant
Copy link

Walkthrough

此PR修复了在动态插入的分组表头设置左冻结后,left样式设置不正确的问题。通过调整表头和单元格的样式设置,确保在有纵向滚动条时,表头右冻结列的定位正确。

Changes

文件 概要
packages/vue/src/grid/package.json 更新了依赖版本信息。
packages/vue/src/grid/src/table/src/utils/autoCellWidth.ts 修复了动态分组表头的样式设置问题,确保在有滚动条时冻结列的定位正确。

columns.forEach((column) => {
columns.forEach((column, index) => {
// 叶子节点则返回
if (index === columns.length - 1) {

Choose a reason for hiding this comment

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

在循环中使用index来判断是否为叶子节点可能会导致错误,因为这假设了叶子节点总是最后一个元素。建议使用更可靠的方法来识别叶子节点,以避免潜在的逻辑错误。

@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 incorrect left style setting after setting the left freeze in the dynamically inserted group header. By adjusting the style settings of the table header and cells, ensure that the frozen column on the right side of the table header is positioned correctly when there is a vertical scroll bar.

Changes

Documentation Summary
packages/vue/src/grid/package.json Updated dependency version information.
packages/vue/src/grid/src/table/src/utils/autoCellWidth.ts Fixed the style setting problem of dynamic group header to ensure that the frozen column is positioned correctly when there are scroll bars.

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)
packages/vue/src/grid/src/table/src/utils/autoCellWidth.ts (1)

179-189: Consider preserving existing styles.

While the changes effectively prevent duplicate style assignments and optimize performance with early returns, the style object initialization could be safer.

Consider this approach to preserve any existing styles:

-        column.style = column.style || {}
+        if (!finishColumns.has(column.id)) {
+          column.style = { ...column.style } // Preserve existing styles
           column.style[direction] = leafDirectionPos
+          finishColumns.add(column.id)
+        }
-        if (!finishColumns.has(column.id)) {
-          column.style[direction] = leafDirectionPos
-          finishColumns.add(column.id)
-        }

This ensures we:

  1. Only modify styles once per column (using finishColumns)
  2. Preserve any existing styles by creating a new object
  3. Set the direction property only when needed
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between e359e86 and 876aeff.

📒 Files selected for processing (2)
  • packages/vue/src/grid/package.json (1 hunks)
  • packages/vue/src/grid/src/table/src/utils/autoCellWidth.ts (2 hunks)
✅ Files skipped from review due to trivial changes (1)
  • packages/vue/src/grid/package.json
🔇 Additional comments (2)
packages/vue/src/grid/src/table/src/utils/autoCellWidth.ts (2)

163-163: LGTM! Good performance optimization.

The introduction of finishColumns Set efficiently prevents duplicate style assignments for the same column.


Line range hint 163-189: Add tests to verify the fixes.

The changes look good and effectively address the style issues. However, to ensure the fixes remain stable:

  1. Add unit tests for the setGroupHeaderPosition function
  2. Include test cases for:
    • Single column groups (early return)
    • Multiple column groups
    • Duplicate style prevention
    • Left/right direction handling

Would you like me to help generate the test cases?

@zzcr zzcr merged commit 988e5e2 into release-3.21.0 Jan 13, 2025
13 of 22 checks passed
@coderabbitai coderabbitai bot mentioned this pull request Jan 13, 2025
13 tasks
@kagol kagol deleted the cgm/group-header-fixed 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.

4 participants