Skip to content

Commit 5d9101e

Browse files
authored
fix(platform): Fix expandable state (#13736)
The previous approach was not working on safari, so we just conditionally render the icon altogether now.
1 parent 9df5593 commit 5d9101e

File tree

2 files changed

+9
-19
lines changed

2 files changed

+9
-19
lines changed

src/components/expandable/index.tsx

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ export function Expandable({title, level = 'info', children, permalink, group}:
5757

5858
function toggleIsExpanded(event: React.MouseEvent<HTMLDetailsElement>) {
5959
const newVal = event.currentTarget.open;
60+
setIsExpanded(newVal);
6061

6162
if (id) {
6263
if (newVal) {
@@ -65,26 +66,22 @@ export function Expandable({title, level = 'info', children, permalink, group}:
6566
window.history.pushState({}, '', '#');
6667
}
6768
}
68-
69-
setIsExpanded(newVal);
7069
}
7170

7271
return (
7372
<details
7473
name={group}
7574
className={`${styles.expandable} callout !block ${'callout-' + level}`}
7675
open={isExpanded}
77-
// We only need this to keep the URL hash in sync
78-
onToggle={id ? toggleIsExpanded : undefined}
76+
onToggle={toggleIsExpanded}
7977
id={id}
8078
>
8179
<summary className={`${styles['expandable-header']} callout-header`}>
82-
<ChevronDownIcon
83-
className={`${styles['expandable-icon-expanded']} callout-icon`}
84-
/>
85-
<ChevronRightIcon
86-
className={`${styles['expandable-icon-collapsed']} callout-icon`}
87-
/>
80+
{isExpanded ? (
81+
<ChevronDownIcon className="callout-icon" />
82+
) : (
83+
<ChevronRightIcon className="callout-icon" />
84+
)}
8885
<div>{title}</div>
8986
</summary>
9087
<div className={`${styles['expandable-body']} callout-body content-flush-bottom`}>

src/components/expandable/style.module.scss

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88
.expandable-body {
99
margin-left: 1.6rem;
1010

11-
& ul, & ol {
11+
& ul,
12+
& ol {
1213
padding-left: 1.2rem;
1314
}
1415
}
@@ -21,12 +22,4 @@
2122
&:not(:open) .expandable-header {
2223
margin-bottom: 0;
2324
}
24-
25-
&:open .expandable-icon-collapsed {
26-
display: none;
27-
}
28-
29-
&:not(:open) .expandable-icon-expanded {
30-
display: none;
31-
}
3225
}

0 commit comments

Comments
 (0)