solid icon indicating copy to clipboard operation
solid copied to clipboard

Bug with Transitions Show vs {cond && <Comp/>}

Open nzdeep opened this issue 2 years ago • 2 comments

Describe the bug

Adding this here just so it doesn't get missed in 2.0 or 2.x milestone if we're beyond 2.0 planning already, understand things are hectic with transition to basing on Astro at the moment. This is bug with transitions where using {cond && <Comp/>} behaves differently Show, the first doesn't use a transition (thus showing Suspense fallback) whilst the later does. Verified by modderme123 on discord

https://playground.solidjs.com/anonymous/e189bc58-107e-4886-a1ff-bc3bda646afe

Your Example Website or App

https://playground.solidjs.com/anonymous/e189bc58-107e-4886-a1ff-bc3bda646afe

Steps to Reproduce the Bug or Issue

Run both variants

Expected behavior

Expect Suspense fallback to never show as wrapped in a Suspense and startTransition

Screenshots or Videos

No response

Platform

1.7.6

Additional context

No response

nzdeep avatar Jun 19 '23 02:06 nzdeep

What's interesting is that the Suspense tag does work when you wrap it around the RHost component within the Show: https://playground.solidjs.com/anonymous/482502b6-ca66-4d84-b927-281b4fb6c322

As soon as you bring it out of it, promise lost: https://playground.solidjs.com/anonymous/429e281a-4b7a-4c96-915e-a2ffca532ddc

Great find! 🔬

caseybaggz avatar Jun 26 '23 19:06 caseybaggz

Yeah ... this is a problem with existing renderEffects not being ran again but rather queued at the end. Which is a necessity with the current setup but also means that any transition code needs to be wrapped in a Memo rather than directly in an effect. Solid 2.0 does aim to solve this but this is a very blatant example. A quick fix would be to wrap ternaries/conditional in Memo's as well on DOM insertion. I can picture some more edge cases though. Like hoisted non-memoized conditional expressions. I think I'm ok with that. That would solve it mostly for now.

ryansolid avatar Jun 26 '23 20:06 ryansolid