Skip to content

bug: Mixin issues when working with slots #6607

@blakeplumb

Description

@blakeplumb

Prerequisites

Stencil Version

"@stencil/core": "4.42.0",

Current Behavior

I have been taking advantage of the new Mixin from stencil core. I love it. It has helped me to share reused logic across components. I ran into an issue though when I added helper methods to render jsx. For example:

    renderLabel = () => (
        <label class="form-field__label" htmlFor={this.controlId}>
          {this.required ? (
            <span class="form-field__required-indicator">*</span>
          ) : null}
          <slot name="label"></slot>
        </label>
    );

The helper works correctly, but because I moved my slot into the mixin when the component is compiled it does not register that there is any slot logic in the component and ignores them.

We are using light DOM components by the way, and simply adding a hidden slot to the component like,
<slot name="__stencil-slot-sentinel__" />
Makes the component work as expected.

Expected Behavior

I would like stencil compiler to crawl the Mixin logic to see if slots are being added via the mixin.

System Info

Steps to Reproduce

Add a Mixin that has a render method that renders a <slot /> and notice it not handling the slot logic if there are not other slots outside of the mixin in the component.

Code Reproduction URL

https://github.com/blakeplumb/fork-stencil-starter

Additional Information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Bug: ValidatedThis PR or Issue is verified to be a bug within Stencil

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions