Skip to content
Closed
Show file tree
Hide file tree
Changes from 4 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
4 changes: 2 additions & 2 deletions packages/@react-aria/utils/src/animation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export function useEnterAnimation(ref: RefObject<HTMLElement | null>, isReady: b
// This can happen when isReady starts as false (e.g. popovers prior to placement calculation).
useLayoutEffect(() => {
if (isAnimationReady && ref.current && 'getAnimations' in ref.current) {
for (let animation of ref.current.getAnimations()) {
for (let animation of ref.current.getAnimations({subtree: true})) {
if (animation instanceof CSSTransition) {
animation.cancel();
}
Expand Down Expand Up @@ -80,7 +80,7 @@ function useAnimation(ref: RefObject<HTMLElement | null>, isActive: boolean, onE
return;
}

let animations = ref.current.getAnimations();
let animations = ref.current.getAnimations({subtree: true});
if (animations.length === 0) {
onEnd();
return;
Expand Down
42 changes: 42 additions & 0 deletions packages/react-aria-components/stories/Popover.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -433,3 +433,45 @@ export const PopoverTriggerWidthExample = () => (
</Popover>
</DialogTrigger>
);

export const PopoverChildElementAnimationExample = () => (
<DialogTrigger>
<Button>
Open popover
</Button>
<Popover
placement="bottom start"
style={{
zIndex: 5
}}>
<Dialog>
<div
className="content"
style={{
background: 'Canvas',
color: 'CanvasText',
border: '1px solid gray',
padding: 30,
transition: 'opacity 0.5s'
}}>
<style>
{`
@starting-style {
.react-aria-Popover .content {
opacity: 0;
}
}
.react-aria-Popover[data-exiting] .content,
Copy link
Member

Choose a reason for hiding this comment

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

This fixes the issue for Safari from what I can tell.

Suggested change
.react-aria-Popover[data-exiting] .content,
@starting-style {
.react-aria-Popover .content {
opacity: 0;
}
}
.react-aria-Popover[data-exiting] .content,

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@snowystinger
Thanks for the Safari testing!

I've added @starting-style to the Storybook example to address the enter animation issue in Safari. However, this is a CSS-level consideration that developers will need to handle in their own implementations when targeting Safari.
I'm not sure of the best way for React Aria to help developers discover this Safari-specific requirement.

Copy link
Member

Choose a reason for hiding this comment

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

Yeah I don't think this should be necessary. data-entering should be enough. If it isn't working, then that's a bug we should investigate.

.react-aria-Popover[data-entering] .content {
opacity: 0;
}
`}
</style>
<p>
The popover waits for child element transitions to complete
</p>
</div>
</Dialog>
</Popover>
</DialogTrigger>
);