stencil icon indicating copy to clipboard operation
stencil copied to clipboard

bug: When i try to integrate with react application, the slot element contains hidden attribute instead of displaying the content. Note: This stencil component is using scoped element.

Open muthupriyashanmugam opened this issue 1 year ago • 8 comments
trafficstars

Prerequisites

Stencil Version

v4.7.0

Current Behavior

The stencil component contains the non shadow dom which renders the slot-based element.

The below-mentioned code is added in the component-a

<div><slot name="cta"/></div>

The below-mentioned code is added to the index.html file

<component-a><div slot="cta"></div></component-a>

But the output shown in the react application

<slot name="cta" hidden>click here</slot>

Expected Behavior

The slot element content should shown in the react application if it is a scoped slot element.

System Info

npm version 10.7.0
node version 20.11.1

Steps to Reproduce

Try to include the slot element in the stencil component and include it in the react application.

Code Reproduction URL

https://github.com/muthupriyashanmugam/stencil-issue

Additional Information

No response

muthupriyashanmugam avatar May 29 '24 21:05 muthupriyashanmugam

@muthupriyashanmugam Have you tried using the latest version of Stencil? We've made some changes to slot behavior for scoped components in releases post v4.7.0 (your reported version). For more information, check out this section of the docs on what has been resolved and how to enable these fixes.

tanner-reits avatar May 30 '24 15:05 tanner-reits

We are using the Stenciljs version ^4.7.0 in the package json. Let me check with the recent version and let you know.

muthupriyashanmugam avatar May 30 '24 19:05 muthupriyashanmugam

@tanner-reits I have tried the latest version of stencil v4.18.0 but still it shows the hidden attribute added to the slot element.

Note: we are using the stencil library as a web component and compiling those code as a react component and used as a react npm module in another react application.

When we use the react application, we face this kind of issue.

muthupriyashanmugam avatar May 30 '24 20:05 muthupriyashanmugam

@tanner-reits Any update on this issue?

muthupriyashanmugam avatar Jun 03 '24 18:06 muthupriyashanmugam

@muthupriyashanmugam Can you create a complete reproduction case including the React portions? That way we can be sure to see the same behavior. Also, in your case, are you using the React output target?

tanner-reits avatar Jun 03 '24 19:06 tanner-reits

Thanks for the issue! This issue has been labeled as needs reproduction. This label is added to issues that need a code reproduction.

Please reproduce this issue in an Stencil starter component library and provide a way for us to access it (GitHub repo, StackBlitz, etc). Without a reliable code reproduction, it is unlikely we will be able to resolve the issue, leading to it being closed.

If you have already provided a code snippet and are seeing this message, it is likely that the code snippet was not enough for our team to reproduce the issue.

For a guide on how to create a good reproduction, see our Contributing Guide.

ionitron-bot[bot] avatar Jun 03 '24 19:06 ionitron-bot[bot]

@tanner-reits Yes, we are using the react output target option to generate the react component. In our case, the slot is adding the hidden attribute rendering when we use it in the react nextjs application.

I have tried to test this case in a sample react application, it's working fine. Then only I come to know that it may be the react nextjs makes an issue.

muthupriyashanmugam avatar Jun 05 '24 13:06 muthupriyashanmugam

@tanner-reits Could you please help me to find out the cause for the issue which i am facing is that if i include my stencil scoped component in a nextjs react application as a node module, it's rendering as a shadow-root component.

muthupriyashanmugam avatar Jun 05 '24 18:06 muthupriyashanmugam

Thanks for the issue! This issue is being closed due to inactivity. If this is still an issue with the latest version of Stencil, please create a new issue and ensure the template is fully filled out.

Thank you for using Stencil!

ionitron-bot[bot] avatar Jul 05 '24 18:07 ionitron-bot[bot]

Then only I come to know that it may be the react nextjs makes an issue.

@muthupriyashanmugam using Stencil in Next.js application might be problematic especially when it comes to server side rendering. We currently actively working on adding support for it in #5831 so I recommend to follow that issue for updates. Thanks!

christian-bromann avatar Jul 08 '24 16:07 christian-bromann