Skip to content

Parent with Child Slot rerender bug #1968

Closed

Description

@dutscher

Stencil version:

 @stencil/[email protected]
 ---
 update: 15.11.2019
 ---
 @stencil/[email protected]
---
 update: 15.01.2020
 ---
 @stencil/[email protected]

I'm submitting a:

[x] bug report
[ ] feature request
[ ] support request => Please do not submit support requests here, use one of these channels: https://stencil-worldwide.herokuapp.com/ or https://forum.ionicframework.com/

Current behavior:
Here is a demo: https://dutscher.github.io/stencilslots/

Here is the code which doesnt work from with comments

render() {
    const classes = [];

    if (this.disabled) {
      classes.push(`${this.componentName}--disabled`);
    }

    return (
      <Host class={classes.join(' ')}>
        Demonstrate slot rerender bug
        {/* this dont rerender slot */}
        <div>
          {/* remove condition: works */}
          {/* wrap with <div />: works */}
          {this.disabled && !!this.tag && (
            <div class="tag" innerHTML={this.tag}/>
          )}
          {/* remove div: works */}
          <div>
            before slot&gt;
            <slot/>
            &lt;after slot
          </div>
        </div>
      </Host>
    );
  }

The <slot /> renders first very well, when a rerender in the parent happens, the <slot /> going away. There is a ugly workarround, you can put a <div />. But logical you dont need this <div/>.
https://github.com/dutscher/stencilslots/blob/master/src/components/parent-workaround/parent.tsx

I got a scenario there i need more than one <div />.

I guess its a vdom diff problem.

Expected behavior:
TSX works without extra empty <div /> and the <slot /> is rendered after parent is rerendered.

Steps to reproduce:
https://dutscher.github.io/stencilslots/

Related code:
https://github.com/dutscher/stencilslots/blob/master/src/components/parent-broken/parent.tsx
https://github.com/dutscher/stencilslots/blob/master/src/components/parent-workaround/parent.tsx

Cheers and thanks for the attention :)

Activity

  1. NKBelousov commented on Dec 25, 2019

    @NKBelousov

    Just confirmed this myself

    @dutscher have you found any workaround?

  2. dutscher commented on Jan 15, 2020

    @dutscher
    Author

    @NKBelousov the worked workarround was, to add enough

    or use booleans in your jsx conditions.

    I updated the master with 1.8.5. The problem is still there!

    https://dutscher.github.io/stencilslots/

    cheers

  3. dutscher commented on Mar 3, 2020

    @dutscher
    Author

    updated to 1.8.10 and no fix for this.
    add enough

    around the slot's fixxes is but its not the fine english way.

    cheers

  4. Aswathprabhu commented on Feb 2, 2021

    @Aswathprabhu

    Facing this in 1.17.3

  5. sajTempler commented on Mar 23, 2021

    @sajTempler

    possible workaround:
    #2036 (comment)

  6. added
    Bug: Validated
    on Jul 17, 2023
  7. 1 remaining item

  8. rwaskiewicz commented on Jan 29, 2024

    @rwaskiewicz
    Member

    The fix for this issue has gone out in today's v4.12.0 release

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Bug: Validatedslot-related

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions