-
Notifications
You must be signed in to change notification settings - Fork 748
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: add 'Keys' variable to enum values and check for hotKeys #2463
feat: add 'Keys' variable to enum values and check for hotKeys #2463
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 68320fe:
|
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.
这啥
content/input/hotkeys/index-en-US.md
Outdated
@@ -180,14 +230,14 @@ function Demo() { | |||
|
|||
| Property | Instructions | type | Default | | |||
|-------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------------------------------|-----------| | |||
| hotKeys | Define keyboard shortcut,[values](https://developer.mozilla.org/en-US/docs/Web/API/UI_Events/Keyboard_event_key_values) | KeyboardEvent.key[] | - | | |||
| blockDefault | Whether to prevent the default behavior of the shortcut | boolean | false | |
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 吧
content/input/hotkeys/index-en-US.md
Outdated
```jsx live=true | ||
import React, { useState } from 'react'; | ||
import { HotKeys, Tag } from '@douyinfe/semi-ui'; | ||
import { HotKeys, Keys, Modal, Tag } from '@douyinfe/semi-ui'; |
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.
把枚举的 Keys 放到 HotKeys 的static 属性上吧,不要让用户单独 import 了,有点分散
packages/semi-ui/hotKeys/index.tsx
Outdated
this.props.onClick(); | ||
notifyHotKey: () => { | ||
if (this.props.onHotKey && typeof this.props.onHotKey === 'function') { | ||
this.props.onHotKey(); |
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.
this.props.onHotKey?.() 然后不要忘记把事件 event 也作为入参
packages/semi-ui/hotKeys/index.tsx
Outdated
if (this.props.getListenerTarget) { | ||
return this.props.getListenerTarget(); | ||
if (this.props.getListenerTarget && typeof this.props.getListenerTarget === 'function') { | ||
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.
加了问号就不用 if 提前判空了
} | ||
}); | ||
|
||
return commonKeyCnt === 1; |
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.
commonKeyCnt 大于一现在是不支持?如果检测到大于一的话,也给个报错吧
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.
现在大于一就有报错
semi-design
|
Project |
semi-design
|
Branch Review |
release
|
Run status |
|
Run duration | 10m 11s |
Commit |
|
Committer | 代强 |
View all properties for this run ↗︎ |
Test results | |
---|---|
|
11
|
|
0
|
|
11
|
|
0
|
|
253
|
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
Fixes #
Changelog
🇨🇳 Chinese
Keys
变量,并为用户定义快捷键添加有效性检查🇺🇸 English
Checklist
Other
Additional information