-
Notifications
You must be signed in to change notification settings - Fork 794
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
bug: Slot content went missing within dynamic component #4284
Comments
Hey @AaronKow, thanks for filing this issue and for providing a great reproduction case! I was just able to confirm that although the dynamic I believe this is a case of an underlying issue with Stencil's runtime handling of slots (see for instance these related issues #2004, #2641, #1968, #1997, #2801). I'm going to label this for ingestion into the teams' internal backlog so we can prioritize it. I wasn't able to quickly come up with a straightforward workaround for this issue - possibly you might be able to use a dynamically-applied CSS class to toggle whether your click in clickable or not? Regardless, the current behavior that Stencil has in this regard isn't correct, and apologies for that! Thanks again for reporting and sorry you're running into this issue! |
Is there any workaround if really needs a different dom?
Actuall, I don't need the
|
…hanges (#5120) * fix(runtime): re-relocate slot if parent element's tagname changes If a slot is located in an element and that element's tag is dynamically changed (e.g. from `p` to `span`), we need to re-relocate the slot on re-render STENCIL-672: slot element loses its parent reference and disappears when its parent is rendered conditionally Fixes: #4284, #3913 * add e2e tests * code documentation * put changes behind slot fix flag * resolve new SNC * Apply suggestions from code review Co-authored-by: Ryan Waskiewicz <[email protected]> --------- Co-authored-by: Ryan Waskiewicz <[email protected]>
…onents (#5135) * fix(runtime): re-relocate slot if parent element's tagname changes If a slot is located in an element and that element's tag is dynamically changed (e.g. from `p` to `span`), we need to re-relocate the slot on re-render STENCIL-672: slot element loses its parent reference and disappears when its parent is rendered conditionally Fixes: #4284, #3913 * add e2e tests * code documentation * put changes behind slot fix flag * resolve new SNC * reset `hidden` state of nodes on relocate It is possible for slotted content to still be invisible in the DOM if the slot was not rendered on the first render. This commit resets the `hidden` attribute of a node on successful relocation. STENCIL-1053 * hide slot content without a home in `scoped` components Hides any content that is projected through to a Stencil component that does not have a destination slot. Only for `scoped` components. Fixes #2877 STENCIL-938 * add e2e tests for hiding content without a slot * revert karma config * PR feedback Co-authored-by: Christian Bromann <[email protected]> --------- Co-authored-by: Christian Bromann <[email protected]>
A fix for this issue was released in |
@christian-bromann is the docu under extra-config https://stenciljs.com/docs/config-extras complete for
I can confirm that the v4.8.2 fix our issue:
Thanks for all your good work! |
At my tests with Code base:
Case 1: without Case 2: with The green default slot should be in the green default slot container. Case 3: with Here is a stackblitz playground: Cheers and thanks |
@dutscher interesting 🤔 mind raising a new issue for this so we can triage it? |
@christian-bromann yes i will do a new issue for that. if
reproducable aswell in the stackblitz demo in the cheersi created a issue for that #5215 |
Prerequisites
Stencil Version
3.2.1
Current Behavior
I have a Stencil web component with an
<a>
tag element that needs to be changed to<p>
tag to prevent the user from clicking it.The dynamic component is working, however I noticed that the content that goes to the went missing.
I have a simple component code:
In my
index.html
:It shows the slot content initially, then I tried to change the element dynamically using timeout after 3 seconds.
Then the slot content went missing as show in GIF below:
Expected Behavior
We have the expectation that the slot content still persist after the component tag is changed after 3s:
System Info
Steps to Reproduce
To replicate it, I did it with Stencil Component Starter.
Please refer to the link below for reproduction.
Code Reproduction URL
https://github.com/AaronKow/stencil-slot-missing-issue
Additional Information
No response
The text was updated successfully, but these errors were encountered: