Skip to content

Cannot reuse a dom element when switching mount locations #2357

@thetarnav

Description

@thetarnav

I'm trying to reuse the same dom element, and attach it in different places in the ui.
But even though that element is rendered only in one place at a time, solid's rendering of it is not stable.
Sometimes the element is added correctly, sometimes it's removed from the dom completely and sometimes it appears in the wrong spot.

const my_dom_element = document.createElement('div')

return <>
	<div>
		<Show when={something() === 'foo'}>
			{my_dom_element}
		</Show>
	</div>
	<div>
		<Show when={something() === 'bar'}>
			{my_dom_element}
		</Show>
	</div>	
</>

Playground link:
https://playground.solidjs.com/anonymous/d2ce885b-d473-4641-94a6-d9c659bc1e22

I know that this can be "solved" by creating new elements and animating them as if they were the old one. But that is besides the point.
This just seems like something that should work.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions