Skip to content

Commit

Permalink
prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
KonnorRogers committed Jul 17, 2024
1 parent 50d1c91 commit 2524b40
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 17 deletions.
2 changes: 1 addition & 1 deletion docs/pages/resources/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -1761,4 +1761,4 @@ The following pages demonstrate why this change was necessary.

## 2.0.0-beta.1

- Initial release
- Initial release
8 changes: 4 additions & 4 deletions src/components/menu/menu.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,14 @@ export default class SlMenu extends ShoelaceElement {
private handleClick(event: MouseEvent) {
const menuItemTypes = ['menuitem', 'menuitemcheckbox'];

const composedPath = event.composedPath()
const composedPath = event.composedPath();
const target = composedPath.find((el: Element) => menuItemTypes.includes(el?.getAttribute?.('role') || ''));

if (!target) return;

const closestMenu = composedPath.find((el: Element) => el?.getAttribute?.("role") === "menu")
const clickHasSubmenu = closestMenu !== this
if (clickHasSubmenu) return
const closestMenu = composedPath.find((el: Element) => el?.getAttribute?.('role') === 'menu');
const clickHasSubmenu = closestMenu !== this;
if (clickHasSubmenu) return;

// This isn't true. But we use it for TypeScript checks below.
const item = target as SlMenuItem;
Expand Down
23 changes: 11 additions & 12 deletions src/components/menu/menu.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import '../../../dist/shoelace.js';
import { clickOnElement } from '../../internal/test.js';
import { aTimeout, expect, fixture } from '@open-wc/testing';
import { expect, fixture } from '@open-wc/testing';
import { html } from 'lit';
import { sendKeys } from '@web/test-runner-commands';
import sinon from 'sinon';
Expand Down Expand Up @@ -123,7 +123,7 @@ it('Should fire "sl-select" when clicking an element within a menu-item', async
expect(selectHandler).to.have.been.calledOnce;
});

it.only("Should be able to check a checkbox menu item in a submenu", async () => {
it.only('Should be able to check a checkbox menu item in a submenu', async () => {
const menu: SlMenu = await fixture(html`
<sl-menu style="max-width: 200px;">
<sl-menu-item>
Expand All @@ -135,14 +135,13 @@ it.only("Should be able to check a checkbox menu item in a submenu", async () =>
</sl-menu>
`);

const menuItem = menu.querySelector<SlMenuItem>('sl-menu-item')!;
const checkbox = menu.querySelector<SlMenuItem>("[type='checkbox']")!;

const menuItem = menu.querySelector<SlMenuItem>("sl-menu-item")!
const checkbox = menu.querySelector<SlMenuItem>("[type='checkbox']")!

expect(checkbox.checked).to.equal(true)
await clickOnElement(menuItem) // Focus the menu item
await sendKeys({ press: "ArrowRight" }) // Open the submenu
await clickOnElement(checkbox) // Click the checkbox
await checkbox.updateComplete
expect(checkbox.checked).to.equal(false)
})
expect(checkbox.checked).to.equal(true);
await clickOnElement(menuItem); // Focus the menu item
await sendKeys({ press: 'ArrowRight' }); // Open the submenu
await clickOnElement(checkbox); // Click the checkbox
await checkbox.updateComplete;
expect(checkbox.checked).to.equal(false);
});

0 comments on commit 2524b40

Please sign in to comment.