Skip to content

Component is hidden and never shown again under <Show /> #2521

@andreevsm

Description

@andreevsm

Describe the bug

Hello! I have three components: ComponentA and ComponentB get ComponentC via props. Depending on isMobile signal,ComponentC is rendered either under ComponentA or ComponentB. But sometimes ComponentC is not displayed in these components. Moreover, sometimes nothing is displayed. So I provided the link who you can reproduce the problem

Your Example Website or App

https://stackblitz.com/edit/solid-vite-h2s1pgwn

Steps to Reproduce the Bug or Issue

  1. Follow the link
  2. Resize the window to 400px to get isMobile = true
  3. Check the displaying of ComponentC
  4. Resize the window to more then 400px to get isMobile = false
  5. Check the displaying of ComponentC

Expected behavior

On more then 400px I expected to see ComponentC under ComponentB - on desktop block
On less then 400px I expected to seeComponentC under ComponentA - on mobile block
But right now ComponentC is displayed unpredictable, sometimes under ComponentA, sometimes under ComponentB and sometimes nothing is displayed.

Screenshots or Videos

Video

As you can see from the video, if you wrap ComponentC in a <div>, the content is displayed as expected, but I don't understand why it works this way? The fix with the <div> doesn't look obvious and I would like to better understand the process of rendering content inside the <Show>.

An additional question is that onMount is called inside ComponentC even when the component has not been rendered. I believe this is happening because of callingchildren(). So how do I make sure that onMount is not called until the component is displayed in the DOM?

Platform

  • OS: macOS
  • Browser: Chrome
  • Version: 138.0.7204.184

Additional context

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions