Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/neat-feet-grow.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@solid-design-system/docs': patch
---

Fixed menu template dropdowns closing on clicks outside the dropdown component.
30 changes: 28 additions & 2 deletions packages/docs/src/stories/templates/menu.stories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,20 @@ export default {

export const MenuWithIcons = {
name: 'Menu with Icons',
parameters: {
docs: { story: { autoplay: true } }
},
play: async ({ canvasElement }: { canvasElement: HTMLElement }) => {
await customElements.whenDefined('sd-dropdown');

const dropdown = canvasElement.querySelector<HTMLElement & { containingElement: HTMLElement }>('#menu-with-icons');

if (dropdown) {
dropdown.containingElement = canvasElement.ownerDocument.body;
}
},
render: () =>
html` <sd-dropdown distance="4" rounded open stay-open-on-select>
html` <sd-dropdown id="menu-with-icons" distance="4" rounded open stay-open-on-select>
<sd-button variant="secondary" slot="trigger">
<sd-icon name="system/more-functions" label="Icon only"></sd-icon>
</sd-button>
Expand All @@ -61,8 +73,22 @@ export const MenuWithIcons = {

export const MenuWithCheckmarksAndIcons = {
name: 'Menu with Checkmarks and Icons',
parameters: {
docs: { story: { autoplay: true } }
},
play: async ({ canvasElement }: { canvasElement: HTMLElement }) => {
await customElements.whenDefined('sd-dropdown');

const dropdown = canvasElement.querySelector<HTMLElement & { containingElement: HTMLElement }>(
'#menu-with-checkmarks'
);

if (dropdown) {
dropdown.containingElement = canvasElement.ownerDocument.body;
}
},
render: () => html`
<sd-dropdown distance="4" rounded open stay-open-on-select>
<sd-dropdown id="menu-with-checkmarks" distance="4" rounded open stay-open-on-select>
<sd-button variant="secondary" slot="trigger">
<sd-icon name="system/more-functions" label="Icon only"></sd-icon>
</sd-button>
Expand Down
4 changes: 2 additions & 2 deletions packages/mcp/metadata/packages/templates/menu.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ version: 1.0.0
## Template: Menu with Icons

```html
<sd-dropdown distance="4" rounded open stay-open-on-select>
<sd-dropdown id="menu-with-icons" distance="4" rounded open stay-open-on-select>
<sd-button variant="secondary" slot="trigger">
<sd-icon name="system/more-functions" label="Icon only"></sd-icon>
</sd-button>
Expand All @@ -37,7 +37,7 @@ version: 1.0.0
## Template: Menu with Checkmarks and Icons

```html
<sd-dropdown distance="4" rounded open stay-open-on-select>
<sd-dropdown id="menu-with-checkmarks" distance="4" rounded open stay-open-on-select>
<sd-button variant="secondary" slot="trigger">
<sd-icon name="system/more-functions" label="Icon only"></sd-icon>
</sd-button>
Expand Down
Loading