-
Notifications
You must be signed in to change notification settings - Fork 740
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
feat: keyboard short cut #2418
feat: keyboard short cut #2418
Conversation
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. Latest deployment of this branch, based on commit 025e50b:
|
changelog 填填 |
return { | ||
...super.adapter, | ||
notifyClick: () => { | ||
this.props.onClick(); |
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.
onClick 判空
this.props.onClick(); | ||
}, | ||
getListenerTarget: () => { | ||
return this.props.getListenerTarget(); |
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.
同上
|
||
### 不可用 | ||
|
||
设定 `disabled` 属性为 `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.
设定 `disabled` 属性为 `true` | |
设定 `disabled` 属性为 `true` 时,不监听 hotKeys。 |
``` | ||
### 基本 | ||
|
||
基本使用,通过`hotKeys`传入快捷键组合 |
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.
基本使用,通过hotKeys
传入快捷键组合,通过 onClick 绑定快捷键处理函数,作出响应动作。
按下 Ctrl + Shift + A,使得 count + 1。默认在 body 监听,全局生效。
| content | 设置显示内容 | string[] | - | | ||
| onClick | 快捷键触发函数 | () => void | - | | ||
| clickable | 设置函数是否可以点击触发 | boolean | false | | ||
| render | 覆盖组件渲染 | () => ReactNode | | |
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.
ReactNode 支持吗?
``` | ||
|
||
### 修改监听挂载DOM | ||
通过`getListenerTarget`修改快捷键监听挂载的DOM |
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.
快捷键默认在 body 监听,通过 getListenerTarget
修改快捷键监听挂载的 DOM。
return; | ||
} | ||
if (keysPressed.every(Boolean)) { | ||
event.preventDefault(); |
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.
preventDefault 的效果是怎么样的?
会导致其他同名快捷键(比如,ctrl+c)失效吗?如果是这样的话,建议在文档里说明。
如果与全局快捷键冲突,会导致全局快捷键不可用。建议不要占用全局的快捷键。
const { hotKeys, content, onClick, clickable, disabled, render, getListenerTarget, className, style, ...rest } = this.props; | ||
|
||
if (render !== null) { | ||
return render(); |
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.
…emi-design into feat/KeyboardShortCut
…emi-design into feat/KeyboardShortCut
semi-design
|
Project |
semi-design
|
Branch Review |
release
|
Run status |
|
Run duration | 09m 30s |
Commit |
|
Committer | 代强 |
View all properties for this run ↗︎ |
Test results | |
---|---|
|
0
|
|
0
|
|
11
|
|
0
|
|
272
|
Upgrade your plan to view test results. | |
View all changes introduced in this branch ↗︎ |
中文模板 / Chinese Template
What kind of change does this PR introduce? (check at least one)
PR description
Changelog
🇨🇳 Chinese
🇺🇸 English
Checklist
Other
Additional information