Skip to content

Build your own AI office with Univer Office SDK. Bring editing, calculation, collaboration, and file processing into your product for people and AI agents. Built on an extensible open-source core.

fix(sheet): scroll not working when using TAB navigation (#372)

YuHongac183cb09592
diff --git a/packages/base-sheets/src/Controller/scroll.controller.ts b/packages/base-sheets/src/Controller/scroll.controller.ts
index 95095d19f3..82bca791e9 100644
--- a/packages/base-sheets/src/Controller/scroll.controller.ts
+++ b/packages/base-sheets/src/Controller/scroll.controller.ts
@@ -89,7 +89,7 @@ export class ScrollController extends Disposable {
if (selection == null) {
return;
}
- const { startRow: selectionStartRow, startColumn: selectionStartColumn } = selection.range;
+ const { actualRow: selectionStartRow, actualColumn: selectionStartColumn } = selection.primary;
const { rowHeightAccumulation, columnWidthAccumulation } =
this._sheetSkeletonManagerService.getCurrent()?.skeleton ?? {};
if (rowHeightAccumulation == null || columnWidthAccumulation == null) {
@@ -131,11 +131,7 @@ export class ScrollController extends Disposable {
} = skeleton.getRowColumnSegment(bounds);
// vertical overflow only happens when the selection's row is in not the freeze area
- if (
- (direction === Direction.UP || direction === Direction.DOWN) &&
- selectionStartRow >= freezeStartRow &&
- selectionStartColumn >= freezeStartColumn - freezeXSplit
- ) {
+ if (selectionStartRow >= freezeStartRow && selectionStartColumn >= freezeStartColumn - freezeXSplit) {
// top overflow
if (selectionStartRow <= viewportStartRow) {
startSheetViewRow = selectionStartRow;
@@ -153,11 +149,7 @@ export class ScrollController extends Disposable {
}
}
// horizontal overflow only happens when the selection's column is in not the freeze area
- if (
- (direction === Direction.LEFT || direction === Direction.RIGHT) &&
- selectionStartColumn >= freezeStartColumn &&
- selectionStartRow >= freezeStartRow - freezeYSplit
- ) {
+ if (selectionStartColumn >= freezeStartColumn && selectionStartRow >= freezeStartRow - freezeYSplit) {
// left overflow
if (selectionStartColumn <= viewportStartColumn) {
startSheetViewColumn = selectionStartColumn;
diff --git a/packages/ui-plugin-sheets/src/controller/navigation/navigation.controller.ts b/packages/ui-plugin-sheets/src/controller/navigation/navigation.controller.ts
index 6f81eb7026..1683ef1afe 100644
--- a/packages/ui-plugin-sheets/src/controller/navigation/navigation.controller.ts
+++ b/packages/ui-plugin-sheets/src/controller/navigation/navigation.controller.ts
@@ -2,9 +2,13 @@ import { ScrollController } from '@univerjs/base-sheets';
import { Disposable, ICommandService, LifecycleStages, OnLifecycle } from '@univerjs/core';
import { Inject } from '@wendellhu/redi';
-import { IMoveSelectionCommandParams, MoveSelectionCommand } from '../../commands/commands/set-selection.command';
+import {
+ IMoveSelectionCommandParams,
+ MoveSelectionCommand,
+ MoveSelectionEnterAndTabCommand,
+} from '../../commands/commands/set-selection.command';
-const SHEET_NAVIGATION_COMMANDS = [MoveSelectionCommand.id];
+const SHEET_NAVIGATION_COMMANDS = [MoveSelectionCommand.id, MoveSelectionEnterAndTabCommand.id];
@OnLifecycle(LifecycleStages.Rendered, SheetNavigationController)
export class SheetNavigationController extends Disposable {