Skip to content
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

fix: 修复树形表格键盘导航错位的问题 #1991 #2035

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions examples/views/table/scroll/Tree.vue
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@
ref="xTable"
:tree-config="{transform: true, rowField: 'id', parentField: 'parentId'}"
:scroll-y="{gt: 0}"
:mouse-config="{selected: true}"
:checkbox-config="{checkField: 'checked'}"
:edit-config="{trigger: 'dblclick', mode: 'cell', showStatus: true}"
:keyboard-config="{isArrow: true, isDel: true, isEnter: true, isTab: true, isEdit: true}"
:data="demo1.tableData">
<vxe-column type="seq" width="200" tree-node></vxe-column>
<vxe-column field="name" title="Name"></vxe-column>
Expand Down
17 changes: 9 additions & 8 deletions packages/keyboard/src/hook.ts
Original file line number Diff line number Diff line change
Expand Up @@ -230,14 +230,14 @@ const tableKeyboardHook: VxeGlobalHooksHandles.HookOptions = {
// 处理 Tab 键移动
moveTabSelected (args, isLeft, evnt) {
const { editConfig } = props
const { afterFullData, visibleColumn } = internalData
const { afterFullData, visibleColumn, scrollYStore } = internalData
const editOpts = computeEditOpts.value
let targetRow
let targetRowIndex: any
let targetColumnIndex: any
const params = Object.assign({}, args)
const _rowIndex = $xetable.getVTRowIndex(params.row)
const _rowIndex = $xetable.getVMRowIndex(params.row) + scrollYStore.startIndex
const _columnIndex = $xetable.getVTColumnIndex(params.column)
let targetRowIndex = _rowIndex
let targetRow = afterFullData[targetRowIndex]
let targetColumnIndex = params.columnIndex
evnt.preventDefault()
if (isLeft) {
// 向左
Expand All @@ -251,9 +251,10 @@ const tableKeyboardHook: VxeGlobalHooksHandles.HookOptions = {
} else {
targetColumnIndex = _columnIndex - 1
}
// 向右
} else {
if (_columnIndex >= visibleColumn.length - 1) {
// 如果已经是第一列,则移动到上一行
// 如果已经是第最后一列,则移动到下一行
if (_rowIndex < afterFullData.length - 1) {
targetRowIndex = _rowIndex + 1
targetRow = afterFullData[targetRowIndex]
Expand Down Expand Up @@ -329,9 +330,9 @@ const tableKeyboardHook: VxeGlobalHooksHandles.HookOptions = {
},
// 处理可编辑方向键移动
moveSelected (args, isLeftArrow, isUpArrow, isRightArrow, isDwArrow, evnt) {
const { afterFullData, visibleColumn } = internalData
const { afterFullData, visibleColumn, scrollYStore } = internalData
const params = Object.assign({}, args)
const _rowIndex = $xetable.getVTRowIndex(params.row)
const _rowIndex = $xetable.getVMRowIndex(params.row) + scrollYStore.startIndex
const _columnIndex = $xetable.getVTColumnIndex(params.column)
evnt.preventDefault()
if (isUpArrow && _rowIndex > 0) {
Expand Down