From 1a82b936440fcc13c211830fada88c68401ce171 Mon Sep 17 00:00:00 2001 From: Uyarn Date: Tue, 7 Jan 2025 11:15:54 +0800 Subject: [PATCH 1/4] fix(Table): fix default horizontal --- src/_common | 2 +- src/table/base-table.tsx | 4 +++- src/table/hooks/useRowHighlight.ts | 12 ++++++++++++ 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/_common b/src/_common index 53786c5875..788747f15e 160000 --- a/src/_common +++ b/src/_common @@ -1 +1 @@ -Subproject commit 53786c58752401e648cc45918f2a4dbb9e8cecfa +Subproject commit 788747f15eaea1bc7aa641cf8ed28c6cd34b09f2 diff --git a/src/table/base-table.tsx b/src/table/base-table.tsx index 33818b3f79..a566be4b7b 100644 --- a/src/table/base-table.tsx +++ b/src/table/base-table.tsx @@ -176,6 +176,7 @@ export default defineComponent({ clearHoverRow, addRowHoverKeyboardListener, removeRowHoverKeyboardListener, + tableRefTabIndex, } = useHoverKeyboardEvent(props, tableRef); watch(tableElmRef, () => { @@ -394,6 +395,7 @@ export default defineComponent({ horizontalScrollAffixRef, headerTopAffixRef, footerBottomAffixRef, + tableRefTabIndex, }; }, @@ -714,7 +716,7 @@ export default defineComponent({ return (
) { const { data, activeRowType, activeRowKeys, defaultActiveRowKeys, disableSpaceInactiveRow } = toRefs(props); const currentOperationRowIndex = ref(-1); + const tableRefTabIndex = ref(0); const isShiftPressed = ref(false); const shiftSelectionState = ref(false); const areaSelectionStartIndex = ref(-1); @@ -164,6 +167,7 @@ export function useRowHighlight(props: BaseTableProps, tableRef: Ref { const code = e.code || e.key?.trim(); + if (ARROW_DOWN_REG.test(code)) { e.preventDefault(); const index = Math.min(data.value.length - 1, currentOperationRowIndex.value + 1); @@ -214,6 +218,13 @@ export function useRowHighlight(props: BaseTableProps, tableRef: Ref { @@ -238,6 +249,7 @@ export function useRowHighlight(props: BaseTableProps, tableRef: Ref Date: Tue, 7 Jan 2025 11:22:03 +0800 Subject: [PATCH 2/4] fix(Table): fix default horizontal --- src/table/hooks/useHoverKeyboardEvent.ts | 20 +++++++++++++++++++- src/table/hooks/useRowHighlight.ts | 9 --------- 2 files changed, 19 insertions(+), 10 deletions(-) diff --git a/src/table/hooks/useHoverKeyboardEvent.ts b/src/table/hooks/useHoverKeyboardEvent.ts index 830156a77c..c32a5eb481 100644 --- a/src/table/hooks/useHoverKeyboardEvent.ts +++ b/src/table/hooks/useHoverKeyboardEvent.ts @@ -2,7 +2,16 @@ import { toRefs, Ref, ref, computed } from 'vue'; import get from 'lodash/get'; import { BaseTableProps } from '../interface'; import { on, off } from '../../utils/dom'; -import { ALL_REG, ARROW_DOWN_REG, ARROW_UP_REG, CLEAR_REG, ESCAPE_REG, SPACE_REG } from '../../_common/js/common'; +import { + ALL_REG, + ARROW_DOWN_REG, + ARROW_UP_REG, + CLEAR_REG, + ESCAPE_REG, + SPACE_REG, + ARROW_LEFT_REG, + ARROW_RIGHT_REG, +} from '../../_common/js/common'; import { RowEventContext, TableRowData } from '../type'; /** @@ -13,6 +22,7 @@ export function useHoverKeyboardEvent(props: BaseTableProps, tableRef: Ref(); const currentHoverRowIndex = ref(-1); + const tableRefTabIndex = ref(0); // 单行高亮场景,不需要键盘悬浮效果 const needKeyboardRowHover = computed(() => { @@ -67,6 +77,13 @@ export function useHoverKeyboardEvent(props: BaseTableProps, tableRef: Ref { @@ -83,6 +100,7 @@ export function useHoverKeyboardEvent(props: BaseTableProps, tableRef: Ref) { const { data, activeRowType, activeRowKeys, defaultActiveRowKeys, disableSpaceInactiveRow } = toRefs(props); const currentOperationRowIndex = ref(-1); - const tableRefTabIndex = ref(0); const isShiftPressed = ref(false); const shiftSelectionState = ref(false); const areaSelectionStartIndex = ref(-1); @@ -218,13 +217,6 @@ export function useRowHighlight(props: BaseTableProps, tableRef: Ref { @@ -249,7 +241,6 @@ export function useRowHighlight(props: BaseTableProps, tableRef: Ref Date: Tue, 7 Jan 2025 11:25:48 +0800 Subject: [PATCH 3/4] fix(Table): fix default horizontal --- src/table/hooks/useRowHighlight.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/table/hooks/useRowHighlight.ts b/src/table/hooks/useRowHighlight.ts index 193007687e..68bf6a16fb 100644 --- a/src/table/hooks/useRowHighlight.ts +++ b/src/table/hooks/useRowHighlight.ts @@ -7,8 +7,6 @@ import { on, off } from '../../utils/dom'; import { ARROW_DOWN_REG, ARROW_UP_REG, - ARROW_LEFT_REG, - ARROW_RIGHT_REG, ESCAPE_REG, SPACE_REG, SHIFT_REG, From 35b889c3125778fdd07f83a36d516c40eff0d05a Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Thu, 16 Jan 2025 09:20:52 +0000 Subject: [PATCH 4/4] chore: update common --- src/_common | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/_common b/src/_common index 788747f15e..01a5dbe678 160000 --- a/src/_common +++ b/src/_common @@ -1 +1 @@ -Subproject commit 788747f15eaea1bc7aa641cf8ed28c6cd34b09f2 +Subproject commit 01a5dbe6785dea1897f0298812c63a5c90dfe0c2