Skip to content

Conversation

@gimmyhehe
Copy link
Member

@gimmyhehe gimmyhehe commented Dec 18, 2025

PR

修复插入的数据rowIndex不正确问题

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

Release Notes

  • Bug Fixes

    • Improved cache synchronization in the grid to automatically update following record insert and delete operations, ensuring internal data structures accurately reflect table modifications and preventing potential data display inconsistencies.
  • Improvements

    • Optimized cache management to enhance grid reliability and data consistency across all table operations.

✏️ Tip: You can customize this high-level summary in your review settings.

@github-actions github-actions bot added the bug Something isn't working label Dec 18, 2025
@coderabbitai
Copy link

coderabbitai bot commented Dec 18, 2025

Walkthrough

Cache management updates were implemented across two methods files. The edit methods now invoke updateCache after insert and remove operations to maintain consistency. Additionally, updateCache's data source was switched from rawData to tableFullData to ensure cache reflects the correct data state.

Changes

Cohort / File(s) Summary
Cache synchronization in edit operations
packages/vue/src/grid/src/edit/src/methods.ts
Added updateCache() calls after record insertion and removal operations to ensure cache state reflects current table data before downstream UI updates
Data source refactor in cache builder
packages/vue/src/grid/src/table/src/methods.ts
Refactored updateCache() to derive cache from tableFullData instead of rawData; downstream cache-building logic remains unchanged

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10–15 minutes

  • Verify updateCache() is called at appropriate points in edit lifecycle (after insert/remove)
  • Confirm tableFullData provides the correct superset of data compared to rawData
  • Ensure no unintended side effects from changing the cache source array

Poem

🐰 Cache whispers now flow with every change,
Insert, remove—the tables stay in range,
From fullData's truth our backups are made,
Consistency blooms in this cached parade!

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Title check ✅ Passed The title directly describes the main fix: correcting rowIndex errors for inserted data in the grid component, which aligns with the code changes adding updateCache() calls.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch cgm/fix-insert-rowindex

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

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/methods.ts (1)

410-480: Consider performance optimization for bulk operations.

The current implementation rebuilds the entire cache on every updateCache() call. For typical single insert/remove operations this is fine, but if your grid supports bulk operations (inserting/removing many rows at once), you might want to consider:

  1. Batching: Only call updateCache() once after bulk operations complete
  2. Incremental updates: Update only affected row indexes instead of rebuilding the entire cache

The current implementation is correct and maintainable. This optimization would only be necessary if profiling shows performance issues with bulk operations.

📜 Review details

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 851cab3 and 733f72a.

📒 Files selected for processing (2)
  • packages/vue/src/grid/src/edit/src/methods.ts (2 hunks)
  • packages/vue/src/grid/src/table/src/methods.ts (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: PR E2E Test (pnpm test:e2e3)
  • GitHub Check: verify-main-build
🔇 Additional comments (3)
packages/vue/src/grid/src/edit/src/methods.ts (2)

142-142: Correctly updates cache after inserting records.

This ensures fullDataRowIdData and fullDataRowMap are rebuilt to include the newly inserted rows with correct indexes, fixing the rowIndex error described in the PR.


216-216: Correctly updates cache after removing records.

This maintains cache consistency by recalculating row indexes for all remaining rows after removal, ensuring symmetry with the insert operation.

packages/vue/src/grid/src/table/src/methods.ts (1)

411-412: Critical fix: Cache now reflects current data state including insertions.

Changing the data source from rawData to tableFullData is essential for this fix:

  • rawData: Original data source (doesn't include inserted rows)
  • tableFullData: Current table data (includes inserted rows)

This ensures that when updateCache() is called after insert operations, the cache includes the newly inserted rows with correct indexes.

@gimmyhehe gimmyhehe changed the title fix(grid): fix insert rowIndex error fix(grid): fix insert rowIndex error Dec 19, 2025
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.

2 participants