Skip to content

Commit 42752f9

Browse files
authored
Merge pull request #2969 from SUI-Components/fix-accordion-ios
fix(components/molecule/accordion): fix accordion in iOS Safari 26.4
2 parents e237be9 + 7036990 commit 42752f9

2 files changed

Lines changed: 35 additions & 9 deletions

File tree

components/molecule/accordion/src/AccordionItemPanel.js

Lines changed: 33 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -52,27 +52,53 @@ const AccordionItemPanel = forwardRef(
5252
className={accordionItemPanelClassName}
5353
aria-disabled={disabled}
5454
style={{
55-
overflowY: height > maxHeight && maxHeight !== 0 ? 'scroll' : 'hidden',
56-
transition: `max-height ${animationDuration}ms ${
55+
// grid-template-rows animation is layout-safe: siblings are pushed down
56+
// correctly in all browsers including iOS Safari ≥16.4.
57+
// max-height animation was replaced because it requires transform/will-change
58+
// hacks to avoid Safari repaint corruption, and those hacks break document flow.
59+
display: 'grid',
60+
gridTemplateRows: values.includes(value) ? '1fr' : '0fr',
61+
transition: `grid-template-rows ${animationDuration}ms ${
5762
values.includes(value) ? 'ease-out' : 'ease-in'
5863
}, opacity 0s linear ${values.includes(value) ? 0 : animationDuration}ms, border-top-width 0s linear ${
5964
values.includes(value) ? 0 : animationDuration
60-
}ms`,
61-
...(values.includes(value) && {
62-
maxHeight: maxHeight === 0 ? height : maxHeight
63-
})
65+
}ms`
6466
}}
6567
{...props}
6668
>
6769
<Poly
6870
as={as}
71+
// overflow:hidden + min-height:0 must be on the direct grid child so that
72+
// grid-template-rows:0fr can collapse it to zero height. These cannot live
73+
// inside the !isFragment spread because isFragment is a function (always truthy),
74+
// making !isFragment always false — the spread never executes.
75+
style={{
76+
// overflow must be 'hidden' while collapsed so 0fr clips the content.
77+
// Once expanded, switch to 'visible' so popovers/dropdowns inside the
78+
// panel can overflow outside its bounds (e.g. make/model picker on desktop).
79+
overflow: values.includes(value) ? 'visible' : 'hidden',
80+
minHeight: 0
81+
}}
6982
{...{
7083
...(!isFragment && {
7184
className: `${BASE_CLASS_ITEM_PANEL_CONTENT}Wrapper`
7285
})
7386
}}
7487
>
75-
<div className={`${BASE_CLASS_ITEM_PANEL_CONTENT}WrapperRef`} ref={contentRef}>
88+
<div
89+
className={`${BASE_CLASS_ITEM_PANEL_CONTENT}WrapperRef`}
90+
ref={contentRef}
91+
style={{
92+
overflow: values.includes(value) ? 'visible' : 'hidden',
93+
minHeight: 0,
94+
// maxHeight prop caps panel height and enables scroll — applied here (not on
95+
// the outer grid wrapper) so it constrains content without affecting the animation
96+
...(maxHeight !== 0 && {
97+
maxHeight,
98+
overflowY: height > maxHeight ? 'scroll' : 'hidden'
99+
})
100+
}}
101+
>
76102
{inject(children, [
77103
{
78104
props: {

components/molecule/accordion/src/styles/index.scss

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,10 +174,10 @@ $base-class-item-panel: '#{$base-class-item}Panel';
174174
}
175175

176176
#{$base-class-item-panel} {
177-
overflow: hidden;
177+
// overflow and collapse are handled by grid-template-rows animation (JS inline style).
178+
// overflow: hidden lives on the inner WrapperRef child (required for 0fr collapse to work).
178179

179180
&--collapsed {
180-
max-height: 0;
181181
opacity: 0;
182182
border-bottom: 0;
183183
}

0 commit comments

Comments
 (0)