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.
TypeScript boardcollaborationdocdocxexceloffce365officepdfpptpptxpresentationsdksheetslidesspreadsheetuniverwordwordprocessorworkspacexlsx
fix: optimize the behavior of editing cells in the last row/column of the worksheet (#6278)
wpxp123456b446ecd4df27
diff --git a/packages/sheets-ui/src/commands/commands/set-selection.command.ts b/packages/sheets-ui/src/commands/commands/set-selection.command.tsindex c16c465498..c7186984db 100644--- a/packages/sheets-ui/src/commands/commands/set-selection.command.ts+++ b/packages/sheets-ui/src/commands/commands/set-selection.command.ts@@ -269,8 +269,13 @@ export const MoveSelectionEnterAndTabCommand: ICommand<IMoveSelectionEnterAndTab});}- // the start range is from the primary selection range- const next = findNextRange(startRange, direction, worksheet);+ /**+ * The start range is from the primary selection range.+ * If the edited cell is the last row/column of the worksheet, and the submitted operation is Enter/Tab to move down/right, the next selected cell should still be the current cell (not move to the first row/column of the worksheet).+ */+ const isLastRowCell = keycode === KeyCode.ENTER && direction === Direction.DOWN && startRange.endRow === worksheet.getMaxRows() - 1;+ const isLastColumnCell = keycode === KeyCode.TAB && direction === Direction.RIGHT && startRange.endColumn === worksheet.getMaxColumns() - 1;+ const next = (isLastRowCell || isLastColumnCell) ? startRange : findNextRange(startRange, direction, worksheet);const destRange = getCellAtRowCol(next.startRow, next.startColumn, worksheet);if (Rectangle.equals(destRange, startRange)) {