Skip to content

Conversation

gimmyhehe
Copy link
Member

@gimmyhehe gimmyhehe commented Jan 9, 2025

PR

修复当配置了boardConfig.isEdit为true时,激活编辑被一直重复触发
PixPin_2025-01-09_17-32-36

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

close #2321

Summary by CodeRabbit

  • Bug Fixes
    • Improved cell editing behavior in the grid component
    • Enhanced keyboard interaction logic to prevent redundant edit actions
    • Refined cell selection and editing state management

Copy link

coderabbitai bot commented Jan 9, 2025

Walkthrough

The pull request introduces modifications to the grid component's key event handling in Vue. The changes focus on improving the behavior of cell editing interactions by adjusting how non-functional key presses are processed. Specifically, the modifications prevent automatically clearing cell values and add more precise conditions for triggering edit modes, enhancing the grid's interaction logic.

Changes

File Change Summary
packages/vue/src/grid/src/table/src/events.ts Removed line that sets cell value to null when a non-functional key is pressed
packages/vue/src/grid/src/table/src/utils/handleGlobalKeydownEvent.ts Updated rule10 function to include actived parameter and added condition to prevent redundant edit actions

Possibly related PRs

Suggested labels

bug

Suggested reviewers

  • zzcr

Poem

🐰 In the grid of code, keys dance and play,
No more null values to sweep away,
Edits precise, with rabbit-like care,
Cells now whisper their stories rare,
A symphony of interactions, hooray! 🎉

Finishing Touches

  • 📝 Generate Docstrings

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 9, 2025
Copy link

Walkthrough

此PR修复了当boardConfig.isEdit设置为true时,单元格激活编辑状态被重复触发的问题。通过在rule10函数中增加对当前激活单元格的检查,避免了重复触发。

Changes

文件 摘要
packages/vue/src/grid/src/table/src/events.ts 移除了在非功能键按下时对单元格值的重置操作。
packages/vue/src/grid/src/table/src/utils/handleGlobalKeydownEvent.ts 修改了rule10函数,增加了对当前激活单元格的检查,防止重复触发激活状态。

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

104-104: Translate comment to English for consistency.

Consider translating the Chinese comment to English:

-// 如果同一个单元格已经被激活编辑态,那么就不重复触发
+// Skip triggering if the same cell is already in edit mode
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 4adc5f1 and 47fb26a.

📒 Files selected for processing (2)
  • packages/vue/src/grid/src/table/src/events.ts (0 hunks)
  • packages/vue/src/grid/src/table/src/utils/handleGlobalKeydownEvent.ts (2 hunks)
💤 Files with no reviewable changes (1)
  • packages/vue/src/grid/src/table/src/events.ts
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: PR E2E Test (pnpm test:e2e3)
  • GitHub Check: PR Unit Test
🔇 Additional comments (4)
packages/vue/src/grid/src/table/src/utils/handleGlobalKeydownEvent.ts (4)

103-103: LGTM! Parameter addition aligns with other rules.

The addition of the actived parameter to rule10 follows the established pattern used in other rules and is necessary for the fix.


106-107: LGTM! Fix prevents repeated edit mode triggers.

The added condition !(selected.row === actived.row && selected.column === actived.column) effectively prevents re-triggering edit mode when a cell is already active, directly addressing the reported issue.


152-152: LGTM! Parameter correctly passed to modified function.

The actived parameter is properly passed to rule10, maintaining consistency with the function signature change.


103-107: Verify similar patterns in other grid components.

Let's verify if there are other places in the codebase that might need similar fixes to prevent repeated triggers.

✅ Verification successful

✓ Fix is complete and correctly isolated

The protection against repeated triggers is specific to keyboard-driven edit mode and is correctly implemented in the only relevant location. Other cell activation flows have their own appropriate protection mechanisms.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for similar patterns in other grid-related files
# Look for edit mode triggers that might need the same fix

# Search for similar rule definitions
rg -l "keyboardConfig.isEdit" "packages/vue/src/grid"

# Search for cell activation patterns
ast-grep --pattern 'selected.$_ === actived.$_' 'packages/vue/src/grid'

Length of output: 387


Script:

#!/bin/bash
# Search for other keyboard event handlers and edit mode triggers
rg -l "isEdit|editConfig" "packages/vue/src/grid"

# Look for any cell activation logic
ast-grep --pattern 'function $_($_) {
  $$$
  actived.$_ 
  $$$
}'

Length of output: 1126


Script:

#!/bin/bash
# Check implementation details in related files
rg "isEdit.*actived" --type ts packages/vue/src/grid -C 3

# Look for similar cell state comparisons
rg "selected\.(row|column).*actived\.(row|column)" --type ts packages/vue/src/grid -C 3

# Check cell activation handlers
cat packages/vue/src/grid/src/edit/src/utils/handleActived.ts

Length of output: 5999

@zzcr zzcr merged commit e359e86 into release-3.21.0 Jan 13, 2025
18 of 27 checks passed
zzcr pushed a commit that referenced this pull request Jan 13, 2025
…sEdit is set true (#2770)

* fix(grid): [grid] fix repeated trigger cell active when boardConfig.isEdit is set true

* fix(grid): [grid] fix value to be set null when keyboard enter edit
kagol pushed a commit that referenced this pull request Jan 13, 2025
…sEdit is set true (#2770)

* fix(grid): [grid] fix repeated trigger cell active when boardConfig.isEdit is set true

* fix(grid): [grid] fix value to be set null when keyboard enter edit
@kagol kagol deleted the cgm/fix-grid-keyboard-config 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.

2 participants