stencil icon indicating copy to clipboard operation
stencil copied to clipboard

Parent with Child Slot rerender bug

Open dutscher opened this issue 7 years ago • 6 comments

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 :)

dutscher avatar Oct 23 '19 13:10 dutscher

Just confirmed this myself

@dutscher have you found any workaround?

NKBelousov avatar Dec 25 '19 21:12 NKBelousov

@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

dutscher avatar Jan 15 '20 10:01 dutscher

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

dutscher avatar Mar 03 '20 12:03 dutscher

Facing this in 1.17.3

Aswathprabhu avatar Feb 02 '21 06:02 Aswathprabhu

possible workaround: https://github.com/ionic-team/stencil/issues/2036#issuecomment-804839788

sajTempler avatar Mar 23 '21 11:03 sajTempler

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

rwaskiewicz avatar Jan 29 '24 16:01 rwaskiewicz