Skip to content

Commit ed41def

Browse files
authored
fix: reduce items on menu if elsewhere in the UI (openscd#1256)
* fix: reduce items on menu if elsewhere in the UI * chore: removed tests for log and diag menu click * chore: action items dont need to render in menu
1 parent a71b667 commit ed41def

File tree

3 files changed

+4
-77
lines changed

3 files changed

+4
-77
lines changed

src/Hosting.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,7 @@ export function Hosting<
237237
renderMenuItem(me: MenuItem | 'divider'): TemplateResult {
238238
if (me === 'divider')
239239
return html`<li divider padded role="separator"></li>`;
240+
if (me.actionItem) return html``;
240241
return html`
241242
<mwc-list-item
242243
class="${me.kind}"
@@ -288,7 +289,9 @@ export function Hosting<
288289
// if clause not neccassary when oscd... compenents in open-scd not list
289290
if (ae.target instanceof List)
290291
(<MenuItem>(
291-
this.menu.filter(item => item !== 'divider')[ae.detail.index]
292+
this.menu.filter(
293+
item => item !== 'divider' && !item.actionItem
294+
)[ae.detail.index]
292295
))?.action?.(ae);
293296
}}
294297
>

test/integration/__snapshots__/open-scd.test.snap.js

Lines changed: 0 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -76,38 +76,6 @@ snapshots["open-scd looks like its snapshot"] =
7676
role="separator"
7777
>
7878
</li>
79-
<mwc-list-item
80-
aria-disabled="true"
81-
class="static"
82-
disabled=""
83-
graphic="icon"
84-
iconid="undo"
85-
mwc-list-item=""
86-
tabindex="-1"
87-
>
88-
<mwc-icon slot="graphic">
89-
undo
90-
</mwc-icon>
91-
<span>
92-
Undo
93-
</span>
94-
</mwc-list-item>
95-
<mwc-list-item
96-
aria-disabled="true"
97-
class="static"
98-
disabled=""
99-
graphic="icon"
100-
iconid="redo"
101-
mwc-list-item=""
102-
tabindex="-1"
103-
>
104-
<mwc-icon slot="graphic">
105-
redo
106-
</mwc-icon>
107-
<span>
108-
Redo
109-
</span>
110-
</mwc-list-item>
11179
<mwc-list-item
11280
aria-disabled="true"
11381
class="validator"
@@ -144,36 +112,6 @@ snapshots["open-scd looks like its snapshot"] =
144112
</mwc-list-item>
145113
<oscd-plugin186320cdd626e422 class="plugin validator">
146114
</oscd-plugin186320cdd626e422>
147-
<mwc-list-item
148-
aria-disabled="false"
149-
class="static"
150-
graphic="icon"
151-
iconid="history"
152-
mwc-list-item=""
153-
tabindex="-1"
154-
>
155-
<mwc-icon slot="graphic">
156-
history
157-
</mwc-icon>
158-
<span>
159-
View log
160-
</span>
161-
</mwc-list-item>
162-
<mwc-list-item
163-
aria-disabled="false"
164-
class="static"
165-
graphic="icon"
166-
iconid="rule"
167-
mwc-list-item=""
168-
tabindex="-1"
169-
>
170-
<mwc-icon slot="graphic">
171-
rule
172-
</mwc-icon>
173-
<span>
174-
View diagnostics
175-
</span>
176-
</mwc-list-item>
177115
<li
178116
divider=""
179117
padded=""

test/integration/open-scd.test.ts

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -47,26 +47,12 @@ describe('open-scd', () => {
4747
expect(element.logUI).to.have.property('open', true);
4848
});
4949

50-
it('opens the log on log menu entry click', async () => {
51-
await (<HTMLElement>(
52-
element.shadowRoot!.querySelector('mwc-list-item[iconid="history"]')!
53-
)).click();
54-
expect(element.logUI).to.have.property('open', true);
55-
});
56-
5750
it('opens the log on snackbar button click', async () => {
5851
expect(element.logUI).to.have.property('open', false);
5952
await element.errorUI.querySelector('mwc-button')!.click();
6053
expect(element.logUI).to.have.property('open', true);
6154
});
6255

63-
it('opens the diagnostics on diagnostics menu entry click', async () => {
64-
await (<HTMLElement>(
65-
element.shadowRoot!.querySelector('mwc-list-item[iconid="rule"]')!
66-
)).click();
67-
expect(element.diagnosticUI).to.have.property('open', true);
68-
});
69-
7056
it('opens the diagnostics on snackbar button click', async () => {
7157
expect(element.diagnosticUI).to.have.property('open', false);
7258
await element.issueUI.querySelector('mwc-button')!.click();

0 commit comments

Comments
 (0)