@@ -10,7 +10,14 @@ import { getDrawerUtilityClass } from "./drawerClasses";
1010import createComponentFactory from "@suid/base/createComponentFactory" ;
1111import createElementRef from "@suid/system/createElementRef" ;
1212import clsx from "clsx" ;
13- import { children , createSignal , Match , onMount , Switch } from "solid-js" ;
13+ import {
14+ children ,
15+ createMemo ,
16+ createSignal ,
17+ Match ,
18+ onMount ,
19+ Switch ,
20+ } from "solid-js" ;
1421
1522const $ = createComponentFactory < DrawerTypeMap > ( ) ( {
1623 name : "MuiDrawer" ,
@@ -190,11 +197,9 @@ const Drawer = $.component(function Drawer({
190197 // We use this state is order to skip the appear transition during the
191198 // initial mount of the component.
192199
193- const [ mounted , setMounted ] = createSignal ( false ) ;
194200 const element = createElementRef ( otherProps ) ;
195201 const theme = useTheme ( ) ;
196202 const resolved = children ( ( ) => props . children ) ;
197- onMount ( ( ) => setMounted ( true ) ) ;
198203
199204 function InternalDrawer ( ) {
200205 return (
@@ -211,6 +216,8 @@ const Drawer = $.component(function Drawer({
211216 }
212217
213218 function SlidingDrawer ( ) {
219+ const [ mounted , setMounted ] = createSignal ( false ) ;
220+ onMount ( ( ) => setMounted ( true ) ) ;
214221 const anchorInvariant = getAnchor ( theme , props . anchor ) as Anchor ;
215222
216223 return (
@@ -225,6 +232,12 @@ const Drawer = $.component(function Drawer({
225232 </ Slide >
226233 ) ;
227234 }
235+ const slidingDrawerVisible = createMemo (
236+ ( ) => props . variant === "persistent" || props . variant === "temporary"
237+ ) ;
238+ const resolvedSlidingDrawer = children (
239+ ( ) => slidingDrawerVisible ( ) && < SlidingDrawer />
240+ ) ;
228241
229242 return (
230243 < Switch >
@@ -245,7 +258,7 @@ const Drawer = $.component(function Drawer({
245258 ownerState = { allProps }
246259 ref = { element }
247260 >
248- < SlidingDrawer />
261+ { resolvedSlidingDrawer ( ) }
249262 </ DrawerDockedRoot >
250263 </ Match >
251264 {
@@ -266,7 +279,7 @@ const Drawer = $.component(function Drawer({
266279 { ...( props . ModalProps ?? { } ) }
267280 transition
268281 >
269- < SlidingDrawer />
282+ { resolvedSlidingDrawer ( ) }
270283 </ DrawerRoot >
271284 </ Match >
272285 }
0 commit comments