Thanks to visit codestin.com
Credit goes to github.com

Skip to content

fix(grid): [grid] fix enter board event do not work #2788

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

Merged
merged 1 commit into from
Jan 13, 2025

Conversation

gimmyhehe
Copy link
Member

@gimmyhehe gimmyhehe commented Jan 13, 2025

PR

修复引拼写错误导致enter键盘事件不生效问题

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

Summary by CodeRabbit

  • Style
    • Improved code clarity by converting variable declarations from let to const
    • Renamed isDwArrow to isDownArrow for better readability

Other information

closes #1969

Copy link

coderabbitai bot commented Jan 13, 2025

Walkthrough

The pull request focuses on refactoring variable declarations in the handleEnterKeyDown function within the Vue grid table events file. The changes primarily involve converting let declarations to const for variables that are not reassigned, such as arrow key detection and children-related variables. Additionally, a variable name was updated from isDwArrow to isDownArrow to improve code readability.

Changes

File Change Summary
packages/vue/src/grid/src/table/src/events.ts - Converted multiple let declarations to const for arrow key and navigation variables
- Renamed isDwArrow to isDownArrow

Possibly related PRs

Suggested labels

bug

Suggested reviewers

  • zzcr

Poem

🐰 In the grid of code, where variables dance,
Const takes the stage with a rabbit's glance
From let to const, clarity springs
Down arrows renamed on coding's wings
A refactor's tale, simple 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.

Copy link

Walkthrough

此PR修复了在网格组件中按下Enter键事件不生效的问题。主要修改包括修正变量声明方式和修复拼写错误,以确保键盘事件的正确处理。

Changes

文件 概要
packages/vue/src/grid/src/table/src/events.ts 修正了变量声明方式,将let改为const,并修复了拼写错误isDwArrowisDownArrow,以确保键盘事件的正确处理。

@github-actions github-actions bot added the bug Something isn't working label Jan 13, 2025
// 如果是激活状态,退则出到下一行
if (selected.row || actived.row) {
this.moveSelected({
args: selected.row ? selected.args : actived.args,
isLeftArrow,
isUpArrow,
isRightArrow,
isDwArrow: true,
isDownArrow: true,

Choose a reason for hiding this comment

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

修复拼写错误:将isDwArrow更正为isDownArrow,确保键盘事件的正确处理。

@Issues-translate-bot
Copy link

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


Walkthrough

This PR fixes the problem that the Enter key event does not take effect in the grid component. The main modifications include correcting the way variables are declared and fixing spelling errors to ensure correct handling of keyboard events.

Changes

Documentation Summary
packages/vue/src/grid/src/table/src/events.ts Fixed the variable declaration method, changed let to const, and fixed the spelling error isDwArrow to isDownArrow to ensure Correct handling of keyboard events.

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: 1

🧹 Nitpick comments (2)
packages/vue/src/grid/src/table/src/events.ts (2)

97-99: LGTM! Consider modernizing keyboard event handling.

The conversion to const is appropriate as these values are not reassigned. However, event.keyCode is deprecated.

Consider using event.key or event.code instead:

-  const isLeftArrow = event.keyCode === 37
-  const isUpArrow = event.keyCode === 38
-  const isRightArrow = event.keyCode === 39
+  const isLeftArrow = event.key === 'ArrowLeft'
+  const isUpArrow = event.key === 'ArrowUp'
+  const isRightArrow = event.key === 'ArrowRight'

112-115: LGTM! Consider adding null check for children array.

The conversion to const and fixing the grammar from childrens to children are good improvements. However, the code could be more defensive.

Consider adding a null check:

-    const children = currentRow[treeConfig.children]
-    if (children && children.length) {
+    const children = currentRow[treeConfig.children] ?? []
+    if (children.length) {
📜 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 8473af1.

📒 Files selected for processing (1)
  • packages/vue/src/grid/src/table/src/events.ts (1 hunks)
🔇 Additional comments (1)
packages/vue/src/grid/src/table/src/events.ts (1)

97-115: Clarify how these changes fix the enter key issue.

While the code quality improvements are good, it's unclear how these changes address the reported issue where the "enter board event do not work". The hardcoded isDownArrow: true might be related to the problem.

Could you please clarify:

  1. What was causing the enter key issue?
  2. How do these changes fix it?
  3. What tests were performed to verify the fix?

// 如果是激活状态,退则出到下一行
if (selected.row || actived.row) {
this.moveSelected({
args: selected.row ? selected.args : actived.args,
isLeftArrow,
isUpArrow,
isRightArrow,
isDwArrow: true,
isDownArrow: true,
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Fix inconsistent down arrow key handling.

While other arrow keys are computed based on the event's keyCode, isDownArrow is hardcoded to true. This seems incorrect and might cause unexpected behavior.

Consider computing it like other arrow keys:

-      isDownArrow: true,
+      isDownArrow: event.keyCode === 40,

Committable suggestion skipped: line range outside the PR's diff.

@gimmyhehe gimmyhehe linked an issue Jan 13, 2025 that may be closed by this pull request
@zzcr zzcr merged commit 87d859f into release-3.21.0 Jan 13, 2025
29 of 44 checks passed
@coderabbitai coderabbitai bot mentioned this pull request Jan 13, 2025
13 tasks
@kagol kagol deleted the cgm/fix-enter-keyboard 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]: Grid表格组件的Enter按键无效
3 participants