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 #3912

Task: 3820888
X-original-commit: 56bc356
Signed-off-by: Lucas Lefèvre (lul) <lul@odoo.com>
Signed-off-by: Adrien Minne (adrm) <adrm@odoo.com>
  • Loading branch information
hokolomopo committed Mar 25, 2024
1 parent 97d200f commit 50fc6c5
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 @@ -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("");
});
});
});

0 comments on commit 50fc6c5

Please sign in to comment.