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

[FW][FIX] bottom_bar: disable sheet drag & drop in readonly #3912

Closed
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion src/components/bottom_bar/bottom_bar.ts
Expand Up @@ -223,7 +223,7 @@ export class BottomBar extends Component<Props, SpreadsheetChildEnv> {
}

onSheetMouseDown(sheetId: UID, event: MouseEvent) {
if (event.button !== 0) return;
if (event.button !== 0 || this.env.model.getters.isReadonly()) return;
this.closeMenu();

const visibleSheets = this.getVisibleSheets();
Expand Down
7 changes: 7 additions & 0 deletions tests/bottom_bar/bottom_bar_component.test.ts
Expand Up @@ -845,5 +845,12 @@ describe("BottomBar component", () => {
await dragSheet("Sheet1", { mouseMoveX: 10, mouseUp: false });
expect(fixture.querySelector(".o-menu")).toBeFalsy();
});

test("Cannot drag & drop sheets in readonly mode", async () => {
model.updateMode("readonly");
await dragSheet("Sheet1", { mouseMoveX: 10, mouseUp: false });
expect(getElComputedStyle('.o-sheet[data-id="Sheet1"]', "position")).toBe("");
expect(getElComputedStyle('.o-sheet[data-id="Sheet1"]', "left")).toBe("");
});
});
});