Skip to content

Commit

Permalink
fix: Fix transitionEnd capturing children transitions (#548)
Browse files Browse the repository at this point in the history
Closes #531
  • Loading branch information
diegohaz committed Feb 9, 2020
1 parent 9a84c70 commit 4cf1eaa
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions packages/reakit/src/Disclosure/DisclosureRegion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,16 @@ export const useDisclosureRegion = createHook<
setHiddenClass(!options.visible ? "hidden" : null);
}, [options.visible]);

const onTransitionEnd = React.useCallback(() => {
if (options.unstable_animated && options.unstable_stopAnimation) {
options.unstable_stopAnimation();
}
}, [options.unstable_animated, options.unstable_stopAnimation]);
const onTransitionEnd = React.useCallback(
(event: React.TransitionEvent) => {
if (event.currentTarget !== event.target) return;

if (options.unstable_animated && options.unstable_stopAnimation) {
options.unstable_stopAnimation();
}
},
[options.unstable_animated, options.unstable_stopAnimation]
);

const animating = options.unstable_animated && options.unstable_animating;
const hidden = !options.visible && !animating;
Expand Down

0 comments on commit 4cf1eaa

Please sign in to comment.