Skip to content

Commit

Permalink
fix: resolve Safari overflow rendering issue in collapse animations
Browse files Browse the repository at this point in the history
Safari was not correctly applying the `overflow` property during collapse/expand animations, causing visual issues. This fix splits the shorthand `overflow` into `overflowX` and `overflowY`, which ensures proper rendering across all browsers.
  • Loading branch information
akatrukhin committed Sep 25, 2024
1 parent d470a33 commit 3809e6c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "patch",
"comment": "fix: Resolve Safari overflow rendering issue in Collapse component",
"packageName": "@fluentui/react-motion-components-preview",
"email": "[email protected]",
"dependentChangeType": "patch"
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,24 @@ const collapseMotion: PresenceMotionFn<{ animateOpacity?: boolean }> = ({ elemen
const toOpacity = 1;
const fromHeight = '0'; // Could be a custom param in the future: start partially expanded
const toHeight = `${element.scrollHeight}px`;
const overflow = 'hidden';
const overflowHidden = 'hidden';

const duration = motionTokens.durationNormal;
const easing = motionTokens.curveEasyEaseMax;

const enterKeyframes = [
{ opacity: fromOpacity, maxHeight: fromHeight, overflow },
// over
{ opacity: fromOpacity, maxHeight: fromHeight, overflowX: overflowHidden, overflowY: overflowHidden },
// Transition to the height of the content, at 99.99% of the duration.
{ opacity: toOpacity, maxHeight: toHeight, offset: 0.9999, overflow },
{ opacity: toOpacity, maxHeight: toHeight, offset: 0.9999, overflowX: overflowHidden, overflowY: overflowHidden },
// On completion, remove the maxHeight because the content might need to expand later.
// This extra keyframe is simpler than firing a callback on completion.
{ opacity: toOpacity, maxHeight: 'unset', overflow },
{ opacity: toOpacity, maxHeight: 'unset', overflowX: overflowHidden, overflowY: overflowHidden },
];

const exitKeyframes = [
{ opacity: toOpacity, maxHeight: toHeight, overflow },
{ opacity: fromOpacity, maxHeight: fromHeight, overflow },
{ opacity: toOpacity, maxHeight: toHeight, overflowX: overflowHidden, overflowY: overflowHidden },
{ opacity: fromOpacity, maxHeight: fromHeight, overflowX: overflowHidden, overflowY: overflowHidden },
];

return {
Expand Down

0 comments on commit 3809e6c

Please sign in to comment.