Skip to content

Commit

Permalink
[FIX] bottom_bar: disable sheet drag & drop in readonly
Browse files Browse the repository at this point in the history
When the sheet is readonly, the bottom bar should not allow the user to
drag and drop the sheet. Before this commit, dragging a sheet was
possible, but the sheet was not moved when dropping. Now we prevent
dragging the sheet when it is readonly.

closes #3870

Task: 3820888
Signed-off-by: Lucas Lefèvre (lul) <lul@odoo.com>
  • Loading branch information
hokolomopo committed Mar 25, 2024
1 parent 0d2ee33 commit 56bc356
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/components/bottom_bar/bottom_bar.ts
Expand Up @@ -240,7 +240,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 mouseX = event.clientX;
Expand Down
7 changes: 7 additions & 0 deletions tests/components/bottom_bar.test.ts
Expand Up @@ -825,5 +825,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("");
});
});
});

0 comments on commit 56bc356

Please sign in to comment.