mirror of
https://github.com/tusen-ai/naive-ui.git
synced 2024-12-21 04:50:14 +08:00
refactor(table): clean code
This commit is contained in:
parent
a715dfd545
commit
29577a22d2
@ -290,10 +290,12 @@ export default defineComponent({
|
||||
onKeydown={handleKeyDown}
|
||||
onClick={handleClick}
|
||||
onMousedown={() => {
|
||||
const userCallBack = window.onselectstart
|
||||
window.onselectstart = () => false
|
||||
const preventDefault = (e: Event): void => {
|
||||
e.preventDefault()
|
||||
}
|
||||
window.addEventListener('selectstart', preventDefault)
|
||||
setTimeout(() => {
|
||||
window.onselectstart = userCallBack
|
||||
window.removeEventListener('selectstart', preventDefault)
|
||||
}, 0)
|
||||
}}
|
||||
>
|
||||
|
@ -143,12 +143,9 @@ export default defineComponent({
|
||||
checked: boolean,
|
||||
shiftKey: boolean
|
||||
): void {
|
||||
const lastKey = lastSelectedKey
|
||||
lastSelectedKey = tmNode.key
|
||||
|
||||
if (shiftKey) {
|
||||
const lastIndex = paginatedDataRef.value.findIndex(
|
||||
(item) => item.key === lastKey
|
||||
(item) => item.key === lastSelectedKey
|
||||
)
|
||||
if (lastIndex !== -1) {
|
||||
const currentIndex = paginatedDataRef.value.findIndex(
|
||||
@ -167,6 +164,8 @@ export default defineComponent({
|
||||
} else {
|
||||
doUncheck(rowKeysToCheck)
|
||||
}
|
||||
lastSelectedKey = tmNode.key
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
@ -175,6 +174,7 @@ export default defineComponent({
|
||||
} else {
|
||||
doUncheck(tmNode.key)
|
||||
}
|
||||
lastSelectedKey = tmNode.key
|
||||
}
|
||||
function getScrollContainer (): HTMLElement | null {
|
||||
if (virtualScrollRef.value) {
|
||||
|
Loading…
Reference in New Issue
Block a user