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(sheets): fix the issue of double-clicking automatically filling boundaries (#6448)

wpxp12345621e2e3af2a25
diff --git a/packages/sheets-ui/src/controllers/auto-fill.controller.ts b/packages/sheets-ui/src/controllers/auto-fill.controller.ts
index fe5373afd5..aba02fa6f8 100644
--- a/packages/sheets-ui/src/controllers/auto-fill.controller.ts
+++ b/packages/sheets-ui/src/controllers/auto-fill.controller.ts
@@ -275,24 +275,23 @@ export class AutoFillController extends Disposable {
return source;
}
const matrix = worksheet.getCellMatrix();
- const maxRow = worksheet.getMaxRows() - 1;
- const maxColumn = worksheet.getMaxColumns() - 1;
- let detectEndRow = endRow;
+ const maxRow = worksheet.getMaxRows();
+ const maxColumn = worksheet.getMaxColumns();
+ let detectEndRow = endRow + 1;
// left column first, or consider right column.
- if (startColumn > 0 && matrix.getValue(startRow, startColumn - 1)?.v != null) {
- let cur = startRow;
- while (matrix.getValue(cur, startColumn - 1)?.v != null && cur < maxRow) {
- cur += 1;
+ if (startColumn > 0 && matrix.getValue(detectEndRow, startColumn - 1)?.v != null) {
+ while (matrix.getValue(detectEndRow + 1, startColumn - 1)?.v != null && detectEndRow < maxRow) {
+ detectEndRow += 1;
}
- detectEndRow = cur - 1;
- } else if (endColumn < maxColumn && matrix.getValue(endRow, endColumn + 1)?.v != null) {
- let cur = startRow;
- while (matrix.getValue(cur, endColumn + 1)?.v != null && cur < maxRow) {
- cur += 1;
+ } else if (endColumn < maxColumn - 1 && matrix.getValue(detectEndRow, endColumn + 1)?.v != null) {
+ while (matrix.getValue(detectEndRow + 1, endColumn + 1)?.v != null && detectEndRow < maxRow) {
+ detectEndRow += 1;
}
- detectEndRow = cur - 1;
+ } else {
+ detectEndRow = endRow;
}
+ // If the fill range contains data, stop filling at the first row of data.
for (let i = endRow + 1; i <= detectEndRow; i++) {
for (let j = startColumn; j <= endColumn; j++) {
if (matrix.getValue(i, j)?.v != null) {