Skip to content

Commit 75dfd28

Browse files
committed
fix(disclosure): 🐛 remove callbacks being passed to the dom
1 parent 603a97e commit 75dfd28

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

src/disclosure/disclosure-collapsible-content.ts

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,15 @@ import {
3636
export const useDisclosureCollapsibleContent =
3737
createHook<DisclosureCollapsibleContentOptions>(
3838
({
39+
state,
3940
direction = "vertical",
4041
contentSize = 0,
4142
easing = "cubic-bezier(0.4, 0, 0.2, 1)",
42-
state,
43+
duration,
44+
onExpandStart,
45+
onExpandEnd,
46+
onCollapseStart,
47+
onCollapseEnd,
4348
...props
4449
}) => {
4550
const id = useId(props.id);
@@ -78,7 +83,7 @@ export const useDisclosureCollapsibleContent =
7883
function getTransitionStyles(size: number | string): {
7984
transition?: string;
8085
} {
81-
const _duration = props.duration || getAutoSizeDuration(size);
86+
const _duration = duration || getAutoSizeDuration(size);
8287

8388
return {
8489
transition: `${currentSize} ${_duration}ms ${easing}`,
@@ -88,7 +93,7 @@ export const useDisclosureCollapsibleContent =
8893
useUpdateEffect(() => {
8994
if (state.visible) {
9095
raf(() => {
91-
props.onExpandStart?.();
96+
onExpandStart?.();
9297

9398
mergeStyles({
9499
willChange: `${currentSize}`,
@@ -108,7 +113,7 @@ export const useDisclosureCollapsibleContent =
108113
});
109114
} else {
110115
raf(() => {
111-
props.onCollapseStart?.();
116+
onCollapseStart?.();
112117

113118
const size = isVertical
114119
? getElementHeight(contentRef)
@@ -171,14 +176,14 @@ export const useDisclosureCollapsibleContent =
171176
});
172177
}
173178

174-
props.onExpandEnd?.();
179+
onExpandEnd?.();
175180

176181
// If the height we should be animating to matches the collapsed height,
177182
// it's safe to apply the collapsed overrides
178183
} else if (stylesSize === `${contentSize}px`) {
179184
setStyles(collapsedStyles);
180185

181-
props.onCollapseEnd?.();
186+
onCollapseEnd?.();
182187
}
183188
},
184189
);

0 commit comments

Comments
 (0)