-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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(data-table): support shiftKey check #1026
feat(data-table): support shiftKey check #1026
Conversation
This pull request is being automatically deployed with Vercel (learn more). 🔍 Inspect: https://vercel.com/tusimple/naive-ui/3cSX9ZT2hRib5VxXvoQUEe2orqnP |
Codecov Report
@@ Coverage Diff @@
## main #1026 +/- ##
==========================================
- Coverage 47.14% 47.07% -0.08%
==========================================
Files 511 511
Lines 12590 12612 +22
Branches 3547 3551 +4
==========================================
+ Hits 5936 5937 +1
- Misses 5628 5649 +21
Partials 1026 1026
Continue to review full report at Codecov.
|
src/checkbox/src/Checkbox.tsx
Outdated
@@ -51,7 +51,7 @@ const checkboxProps = { | |||
MaybeArray<(value: boolean) => void> | |||
>, | |||
onUpdateChecked: [Function, Array] as PropType< | |||
MaybeArray<(value: boolean) => void> | |||
MaybeArray<(value: boolean, e?: MouseEvent | KeyboardEvent) => void> |
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.
什么时候会没有事件?
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.
我的想法是,用户传函数进来时,e参数可以不用写
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.
你不写这个 ? 用户也可以传 () => {}
进来。
一个组件接受一个回调的参数意义为“组件会把声明的参数传进来”,用户少写参数无所谓,也就是说你写了 (value, e)
则组件会向回调传入 (value, e),用户传进来
() => {}` 也无所谓,这种情况下只是用户不需要参数,但是组件会传进来。
b396383
to
39fc1ab
Compare
src/checkbox/src/Checkbox.tsx
Outdated
@@ -289,6 +289,7 @@ export default defineComponent({ | |||
onKeyup={handleKeyUp} | |||
onKeydown={handleKeyDown} | |||
onClick={handleClick} | |||
onMousedown={(e) => e.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.
这个不行啊,很危险
这个会影响 focus 状态
@@ -137,10 +139,34 @@ export default defineComponent({ | |||
} = inject(dataTableInjectionKey)! | |||
const scrollbarInstRef = ref<ScrollbarInst | null>(null) | |||
const virtualListRef = ref<VirtualListInst | null>(null) | |||
const lastSelectedIndex = ref<number | null>(null) |
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.
其实我觉得可以用 lastSelectedKey 去做,这样的话不用每次点击都遍历一遍 pageData
顺便一提,这个并非响应式,不需要 ref
c3e27c7
to
16c6ca1
Compare
我总觉得你的 git commit 有点不太对劲,为啥每次都这么多 merge |
#554