Skip to content

Commit 807b5b5

Browse files
authored
Fixed accordions to allow for nesting
1 parent 9fd5ee5 commit 807b5b5

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

packages/accordion/src/Accordion.svelte

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@
4343
let withOpenDialog = false;
4444
4545
function handlePanelMount(event: CustomEvent<SMUIAccordionPanelAccessor>) {
46+
// To make nested accordions work, ensure event sender is a direct child of this accordion
47+
if(event.target.parentNode != element) return;
48+
4649
const accessor = event.detail;
4750
4851
event.stopPropagation();
@@ -61,6 +64,9 @@
6164
}
6265
6366
function handlePanelUnmount(event: CustomEvent<SMUIAccordionPanelAccessor>) {
67+
// To make nested accordions work, ensure event sender is a direct child of this accordion
68+
if(event.target.parentNode != element) return;
69+
6470
const accessor = event.detail;
6571
6672
event.stopPropagation();
@@ -71,6 +77,9 @@
7177
function handlePanelActivate(
7278
event: CustomEvent<{ accessor: SMUIAccordionPanelAccessor }>
7379
) {
80+
// To make nested accordions work, ensure event sender is a direct child of this accordion
81+
if(event.target.parentNode != element) return;
82+
7483
const { accessor } = event.detail;
7584
7685
if (!multiple && !accessor.open) {
@@ -89,6 +98,9 @@
8998
function handlePanelOpening(
9099
event: CustomEvent<{ accessor: SMUIAccordionPanelAccessor }>
91100
) {
101+
// To make nested accordions work, ensure event sender is a direct child of this accordion
102+
if(event.target.parentNode != element) return;
103+
92104
const { accessor } = event.detail;
93105
94106
if (!multiple) {

0 commit comments

Comments
 (0)