Skip to content

Commit 94cacba

Browse files
committed
fix(material): make appear working
1 parent d344de6 commit 94cacba

3 files changed

Lines changed: 42 additions & 11 deletions

File tree

.changeset/forty-forks-shave.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"@suid/material": minor
3+
"@suid/base": minor
4+
---
5+
6+
fix(material): make appear working

packages/base/src/Transition/Transition.tsx

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -139,13 +139,25 @@ export function Transition(inProps: TransitionProps) {
139139

140140
createEffect((firstTime) => {
141141
if (props.in) {
142-
untrack(() => props.onEnter?.());
143-
setStatus("entering");
142+
untrack(() => {
143+
if (status() !== "entering" && status() !== "entered") {
144+
props.onEnter?.();
145+
setStatus("entering");
146+
}
147+
});
144148
} else {
145-
if (!firstTime) {
146-
untrack(() => props.onExit?.());
147-
setStatus("exiting");
148-
}
149+
untrack(() => {
150+
if (!firstTime) {
151+
if (
152+
status() !== "exiting" &&
153+
status() !== "exited" &&
154+
status() !== "unmounted"
155+
) {
156+
props.onExit?.();
157+
setStatus("exiting");
158+
}
159+
}
160+
});
149161
}
150162
return false;
151163
}, true);

packages/material/src/Drawer/Drawer.tsx

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,14 @@ import { getDrawerUtilityClass } from "./drawerClasses";
1010
import createComponentFactory from "@suid/base/createComponentFactory";
1111
import createElementRef from "@suid/system/createElementRef";
1212
import 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

1522
const $ = 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

Comments
 (0)