From de039aae52228f250a05e073db0578387e9e940c Mon Sep 17 00:00:00 2001 From: huakailei <602515131@qq.com> Date: Tue, 7 Feb 2023 22:04:42 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E9=80=89=E4=B8=AD?= =?UTF-8?q?=E9=A1=B9=E7=A7=BB=E5=8A=A8=E8=BE=B9=E7=95=8C=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/keyboard/src/hook.ts | 34 ++++++++++++++++++++++++++-------- 1 file changed, 26 insertions(+), 8 deletions(-) diff --git a/packages/keyboard/src/hook.ts b/packages/keyboard/src/hook.ts index 336451d603..1f0f45850d 100644 --- a/packages/keyboard/src/hook.ts +++ b/packages/keyboard/src/hook.ts @@ -334,14 +334,32 @@ const tableKeyboardHook: VxeGlobalHooksHandles.HookOptions = { const _rowIndex = $xetable.getVTRowIndex(params.row) const _columnIndex = $xetable.getVTColumnIndex(params.column) evnt.preventDefault() - if (isUpArrow && _rowIndex > 0) { - // 移动到上一行 - params.rowIndex = _rowIndex - 1 - params.row = afterFullData[params.rowIndex] - } else if (isDwArrow && _rowIndex < afterFullData.length - 1) { - // 移动到下一行 - params.rowIndex = _rowIndex + 1 - params.row = afterFullData[params.rowIndex] + if (isUpArrow) { + if (_rowIndex > 0) { + // 移动到上一行 + params.rowIndex = _rowIndex - 1 + params.row = afterFullData[params.rowIndex] + } else if (_columnIndex > 0) { + // 移动到上一列最后一行 + params.rowIndex = afterFullData.length - 1 + params.row = afterFullData[params.rowIndex] + params.columnIndex = _columnIndex - 1 + params.column = visibleColumn[params.columnIndex] + } + // 第一行第一列,静默 + } else if (isDwArrow) { + if (_rowIndex < afterFullData.length - 1) { + // 移动到下一行 + params.rowIndex = _rowIndex + 1 + params.row = afterFullData[params.rowIndex] + } else if (_columnIndex < visibleColumn.length - 1) { + // 移动到下一列第一行 + params.rowIndex = 0 + params.row = afterFullData[params.rowIndex] + params.columnIndex = _columnIndex + 1 + params.column = visibleColumn[params.columnIndex] + } + // 最后一列最后一行,静默 } else if (isLeftArrow && _columnIndex) { // 移动到左侧单元格 params.columnIndex = _columnIndex - 1