Skip to content

Commit

Permalink
fix: add editorManager judgement
Browse files Browse the repository at this point in the history
  • Loading branch information
Rui-Sun committed Jun 24, 2024
1 parent 85133bd commit 13711e0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
8 changes: 4 additions & 4 deletions packages/vtable/src/event/listener/container-dom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export function bindContainerDomListener(eventManager: EventManager) {
) {
if (
!(table.options.keyboardOptions?.moveEditCellOnArrowKeys ?? false) &&
(table as ListTableAPI).editorManager.editingEditor
(table as ListTableAPI).editorManager?.editingEditor
) {
// 编辑单元格状态下 如果没有开启方向键切换cell 则退出 。方向键可以在编辑input内移动光标
return;
Expand Down Expand Up @@ -106,7 +106,7 @@ export function bindContainerDomListener(eventManager: EventManager) {
table.selectCell(targetCol, targetRow, e.shiftKey);
if (
(table.options.keyboardOptions?.moveEditCellOnArrowKeys ?? false) &&
(table as ListTableAPI).editorManager.editingEditor
(table as ListTableAPI).editorManager?.editingEditor
) {
// 开启了方向键切换编辑单元格 并且当前已经在编辑状态下 切换到下一个需先退出再进入下个单元格的编辑
(table as ListTableAPI).editorManager.completeEdit();
Expand All @@ -119,7 +119,7 @@ export function bindContainerDomListener(eventManager: EventManager) {
(table as ListTableAPI).editorManager.cancelEdit();
} else if (e.key === 'Enter') {
// 如果按enter键 可以结束当前的编辑 或开启编辑选中的单元格(仅限单选)
if ((table as ListTableAPI).editorManager.editingEditor) {
if ((table as ListTableAPI).editorManager?.editingEditor) {
(table as ListTableAPI).editorManager.completeEdit();
table.getElement().focus();
} else {
Expand Down Expand Up @@ -156,7 +156,7 @@ export function bindContainerDomListener(eventManager: EventManager) {
targetCol = stateManager.select.cellPos.col + 1;
}
table.selectCell(targetCol, targetRow);
if ((table as ListTableAPI).editorManager.editingEditor) {
if ((table as ListTableAPI).editorManager?.editingEditor) {
(table as ListTableAPI).editorManager.completeEdit();
table.getElement().focus();
if ((table as ListTableAPI).getEditor(targetCol, targetRow)) {
Expand Down
4 changes: 2 additions & 2 deletions packages/vtable/src/event/listener/table-group.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export function bindTableGroupListener(eventManager: EventManager) {
// }
if (
stateManager.interactionState === InteractionState.grabing &&
!(table as ListTableAPI).editorManager.editingEditor
!(table as ListTableAPI).editorManager?.editingEditor
) {
if (Math.abs(lastX - e.x) + Math.abs(lastY - e.y) >= 1) {
if (stateManager.isResizeCol()) {
Expand All @@ -59,7 +59,7 @@ export function bindTableGroupListener(eventManager: EventManager) {
} else if (
table.eventManager.isDraging &&
stateManager.isSelecting() &&
!(table as ListTableAPI).editorManager.editingEditor
!(table as ListTableAPI).editorManager?.editingEditor
) {
eventManager.dealTableSelect(eventArgsSet, true);
}
Expand Down

0 comments on commit 13711e0

Please sign in to comment.