Skip to content

Commit e053137

Browse files
committed
[FIX] TopbarMenu: specify isReadonlyAllowed
The logic that displays the top-level items of the topbarmenu is isolated from the `Menu` component logic. More specifically, it never checks if the item can be used in readonly and as such, we never took the time to define the key `isReadonlyAllowed` on those menu items. However `RibbonMenu` relies on the logic of `Menu` so in order to display the topbar menu items properly in mobile mode, we need the key `isReadonlyAllowed` to be defined. closes #7415 Task: 5245432 Signed-off-by: Lucas Lefèvre (lul) <[email protected]>
1 parent b5c217f commit e053137

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

src/registries/menus/topbar_menu_registry.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ topbarMenuRegistry
2121
.add("file", {
2222
name: _t("File"),
2323
sequence: 10,
24+
isReadonlyAllowed: true,
2425
})
2526
.addChild("settings", ["file"], {
2627
name: _t("Settings"),
@@ -37,6 +38,7 @@ topbarMenuRegistry
3738
.add("edit", {
3839
name: _t("Edit"),
3940
sequence: 20,
41+
isReadonlyAllowed: true,
4042
})
4143
.addChild("undo", ["edit"], {
4244
...ACTION_EDIT.undo,
@@ -123,6 +125,7 @@ topbarMenuRegistry
123125
.add("view", {
124126
name: _t("View"),
125127
sequence: 30,
128+
isReadonlyAllowed: true,
126129
})
127130
.addChild("unfreeze_panes", ["view"], {
128131
...ACTION_VIEW.unFreezePane,
@@ -216,6 +219,7 @@ topbarMenuRegistry
216219
.add("insert", {
217220
name: _t("Insert"),
218221
sequence: 40,
222+
isReadonlyAllowed: true,
219223
})
220224
.addChild("insert_row", ["insert"], {
221225
...ACTION_INSERT.insertRow,
@@ -329,7 +333,11 @@ topbarMenuRegistry
329333
// FORMAT MENU ITEMS
330334
// ---------------------------------------------------------------------
331335

332-
.add("format", { name: _t("Format"), sequence: 50 })
336+
.add("format", {
337+
name: _t("Format"),
338+
sequence: 50,
339+
isReadonlyAllowed: true,
340+
})
333341
.addChild("format_number", ["format"], {
334342
...formatNumberMenuItemSpec,
335343
name: _t("Number"),
@@ -423,6 +431,7 @@ topbarMenuRegistry
423431
.add("data", {
424432
name: _t("Data"),
425433
sequence: 60,
434+
isReadonlyAllowed: true,
426435
})
427436
.addChild("sort_range", ["data"], {
428437
...ACTION_DATA.sortRange,

tests/bottom_bar/small_bottom_bar_component.test.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,13 @@ describe("Small Bottom Bar", () => {
100100
await click(fixture, ".o-ribbon-menu .o-menu-item[title='Copy']");
101101
expect(fixture.querySelector(".o-ribbon-menu")).toBeNull();
102102
});
103+
104+
test("Can open the top-levels menu in readonly mode", async () => {
105+
model.updateMode("readonly");
106+
await click(fixture, ".bottom-bar-menu .ribbon-toggler");
107+
await click(fixture, ".o-ribbon-menu .o-menu-item[title='View']");
108+
expect(fixture.querySelectorAll(".o-ribbon-menu .o-menu-item")).toHaveLength(4);
109+
});
103110
});
104111

105112
test("scroll is reset when navigating through ribbon menu", async () => {

0 commit comments

Comments
 (0)