Skip to content

Commit deab71c

Browse files
committed
remove one more manually opacity change
1 parent 01e36ac commit deab71c

File tree

1 file changed

+5
-17
lines changed
  • docs/src/app/(private)/experiments/collapsible

1 file changed

+5
-17
lines changed

docs/src/app/(private)/experiments/collapsible/plain.tsx

+5-17
Original file line numberDiff line numberDiff line change
@@ -74,17 +74,17 @@ function PlainCollapsible(props: { defaultOpen?: boolean; keepMounted?: boolean
7474
element.style.setProperty('display', 'block', 'important'); // TODO: maybe this can be set more conditionally
7575

7676
if (height === undefined) {
77+
// the closed transition styles must be set here to transition the first
78+
// opening transition when the panel is BOTH initially closed AND `keepMounted={false}`
7779
if (!shouldCancelInitialOpenTransitionRef.current && !keepMounted) {
78-
// the closed transition styles must be set here to transition the first
79-
// opening transition when the panel is BOTH initially closed AND `keepMounted={false}`
80-
// console.log('handlePanelRef setting opacity 0');
81-
// element.style.opacity = '0';
80+
console.log('handlePanelRef setting opacity 0');
81+
element.style.opacity = '0';
8282

8383
setHeightAndRemoveDisplayProperty(element);
8484

8585
// after setHeight() all the transition properties need to be removed
8686
// console.log('handlePanelRef unsetting inline opacity');
87-
// element.style.removeProperty('opacity');
87+
element.style.removeProperty('opacity');
8888
} else {
8989
setHeightAndRemoveDisplayProperty(element);
9090
}
@@ -181,12 +181,6 @@ function PlainCollapsible(props: { defaultOpen?: boolean; keepMounted?: boolean
181181

182182
/* opening */
183183
panel.style.height = '0px';
184-
// the closed transition styles must be set here to transition all opening
185-
// transitions except the first one when `keepMounted={false}`
186-
if (!shouldCancelInitialOpenTransitionRef.current) {
187-
// console.log('useEnhancedEffect setting opacity 0');
188-
// panel.style.opacity = '0';
189-
}
190184

191185
requestAnimationFrame(() => {
192186
// this is the earliest opportunity to unset the `display` property
@@ -195,12 +189,6 @@ function PlainCollapsible(props: { defaultOpen?: boolean; keepMounted?: boolean
195189

196190
panel.style.removeProperty('height');
197191

198-
if (!shouldCancelInitialOpenTransitionRef.current) {
199-
// remove all the transition properties that were just manually applied
200-
// console.log('useEnhancedEffect unsetting inline opacity');
201-
// panel.style.removeProperty('opacity');
202-
}
203-
204192
setHeight(panel.scrollHeight);
205193
});
206194
} else {

0 commit comments

Comments
 (0)