Skip to content

Commit

Permalink
fix(disclosure): 🐛 remove callbacks being passed to the dom
Browse files Browse the repository at this point in the history
  • Loading branch information
navin-moorthy committed Jun 16, 2022
1 parent 603a97e commit 75dfd28
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions src/disclosure/disclosure-collapsible-content.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,15 @@ import {
export const useDisclosureCollapsibleContent =
createHook<DisclosureCollapsibleContentOptions>(
({
state,
direction = "vertical",
contentSize = 0,
easing = "cubic-bezier(0.4, 0, 0.2, 1)",
state,
duration,
onExpandStart,
onExpandEnd,
onCollapseStart,
onCollapseEnd,
...props
}) => {
const id = useId(props.id);
Expand Down Expand Up @@ -78,7 +83,7 @@ export const useDisclosureCollapsibleContent =
function getTransitionStyles(size: number | string): {
transition?: string;
} {
const _duration = props.duration || getAutoSizeDuration(size);
const _duration = duration || getAutoSizeDuration(size);

return {
transition: `${currentSize} ${_duration}ms ${easing}`,
Expand All @@ -88,7 +93,7 @@ export const useDisclosureCollapsibleContent =
useUpdateEffect(() => {
if (state.visible) {
raf(() => {
props.onExpandStart?.();
onExpandStart?.();

mergeStyles({
willChange: `${currentSize}`,
Expand All @@ -108,7 +113,7 @@ export const useDisclosureCollapsibleContent =
});
} else {
raf(() => {
props.onCollapseStart?.();
onCollapseStart?.();

const size = isVertical
? getElementHeight(contentRef)
Expand Down Expand Up @@ -171,14 +176,14 @@ export const useDisclosureCollapsibleContent =
});
}

props.onExpandEnd?.();
onExpandEnd?.();

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

props.onCollapseEnd?.();
onCollapseEnd?.();
}
},
);
Expand Down

1 comment on commit 75dfd28

@vercel
Copy link

@vercel vercel bot commented on 75dfd28 Jun 16, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

react – ./

react-timelessco.vercel.app
react-git-main-timelessco.vercel.app
adaptui-react.vercel.app

Please sign in to comment.