Skip to content

Commit b632ad0

Browse files
fix(navigation-menu): bottom slot click event (#781)
Co-authored-by: Daniel Leroux <daniel.leroux@siemens.com>
1 parent 4fde4bf commit b632ad0

File tree

2 files changed

+28
-1
lines changed

2 files changed

+28
-1
lines changed

packages/core/src/components/menu/menu.tsx

+4-1
Original file line numberDiff line numberDiff line change
@@ -656,7 +656,10 @@ export class Menu {
656656
{this.i18nSettings}
657657
</ix-menu-item>
658658
) : null}
659-
<slot name="bottom"></slot>
659+
<div onClick={(e) => this.onMenuItemsClick(e)}>
660+
<slot name="bottom"></slot>
661+
</div>
662+
660663
<div id="popover-area"></div>
661664
{this.about ? (
662665
<ix-menu-item

packages/core/src/components/menu/test/menu.ct.ts

+24
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,30 @@ test('should close about by item click', async ({ mount, page }) => {
182182
await expect(settings).not.toBeVisible();
183183
});
184184

185+
test('should close menu by bottom icon click', async ({ mount, page }) => {
186+
await mount(`
187+
<ix-menu>
188+
<ix-menu-item>Random</ix-menu-item>
189+
<ix-menu-item slot="bottom">BottomMenuItem</ix-menu-item>
190+
<ix-menu-about>
191+
</ix-menu-about>
192+
<ix-menu-settings>
193+
</ix-menu-settings>
194+
</ix-menu>
195+
`);
196+
197+
const element = page.locator('ix-menu');
198+
await element.getByRole('button', { name: 'Expand sidebar' }).click();
199+
const innerMenu = element.locator('.menu');
200+
await expect(innerMenu).toHaveClass(/expanded/);
201+
202+
const bottomMenu = element.locator('ix-menu-item[slot="bottom"]');
203+
await bottomMenu.click();
204+
205+
await expect(innerMenu).not.toHaveClass(/expanded/);
206+
await expect(element).toBeVisible();
207+
});
208+
185209
async function clickAboutButton(element: Locator, page: Page) {
186210
const aboutButton = element.locator('ix-menu-item#aboutAndLegal');
187211
await aboutButton.click();

0 commit comments

Comments
 (0)