-
Notifications
You must be signed in to change notification settings - Fork 300
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
Conversation
WalkthroughThe pull request focuses on refactoring variable declarations in the Changes
Possibly related PRs
Suggested labels
Suggested reviewers
Poem
Finishing Touches
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? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
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)
Other keywords and placeholders
CodeRabbit Configuration File (
|
Walkthrough此PR修复了在网格组件中按下Enter键事件不生效的问题。主要修改包括修正变量声明方式和修复拼写错误,以确保键盘事件的正确处理。 Changes
|
// 如果是激活状态,退则出到下一行 | ||
if (selected.row || actived.row) { | ||
this.moveSelected({ | ||
args: selected.row ? selected.args : actived.args, | ||
isLeftArrow, | ||
isUpArrow, | ||
isRightArrow, | ||
isDwArrow: true, | ||
isDownArrow: true, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
修复拼写错误:将isDwArrow
更正为isDownArrow
,确保键盘事件的正确处理。
WalkthroughThis 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
|
There was a problem hiding this 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
orevent.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 fromchildrens
tochildren
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
📒 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:
- What was causing the enter key issue?
- How do these changes fix it?
- 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, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
PR
修复引拼写错误导致enter键盘事件不生效问题
PR Checklist
Please check if your PR fulfills the following requirements:
PR Type
What kind of change does this PR introduce?
What is the current behavior?
Issue Number: N/A
What is the new behavior?
Does this PR introduce a breaking change?
Summary by CodeRabbit
let
toconst
isDwArrow
toisDownArrow
for better readabilityOther information
closes #1969