diff --git a/src/checkbox/src/Checkbox.tsx b/src/checkbox/src/Checkbox.tsx index b817b092b..faf56c2af 100644 --- a/src/checkbox/src/Checkbox.tsx +++ b/src/checkbox/src/Checkbox.tsx @@ -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) }} > diff --git a/src/data-table/src/TableParts/Body.tsx b/src/data-table/src/TableParts/Body.tsx index 35d426f97..01f3f3527 100644 --- a/src/data-table/src/TableParts/Body.tsx +++ b/src/data-table/src/TableParts/Body.tsx @@ -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) {