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(sheet): first sheet hidden #1538

Merged
merged 2 commits into from
Mar 11, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
22 changes: 17 additions & 5 deletions packages/core/src/sheets/workbook.ts
Original file line number Diff line number Diff line change
Expand Up @@ -204,13 +204,25 @@ export class Workbook extends Disposable {
*/
getActiveSheet(): Worksheet {
const currentActive = this.getRawActiveSheet();
if (!currentActive) {
const worksheet = this._worksheets.get(this._snapshot.sheetOrder[0])!;
this.setActiveSheet(worksheet);
return worksheet;
if (currentActive) {
return currentActive;
}

return currentActive;
/**
* If the first sheet is hidden, we should set the first unhidden sheet to be active.
*/
const sheetOrder = this._snapshot.sheetOrder;
for (let i = 0, len = sheetOrder.length; i < len; i++) {
const worksheet = this._worksheets.get(sheetOrder[i]);
if (worksheet && worksheet.isSheetHidden() !== BooleanNumber.TRUE) {
this.setActiveSheet(worksheet);
return worksheet;
}
}

const worksheet = this._worksheets.get(sheetOrder[0])!;
DR-Univer marked this conversation as resolved.
Show resolved Hide resolved
this.setActiveSheet(worksheet);
return worksheet;
}

setActiveSheet(worksheet: Nullable<Worksheet>): void {
Expand Down