Skip to content

bug: slot element loses its parent reference and disappears when its parent is rendered conditionally #3913

Closed

Description

@yigityuce

Prerequisites

Stencil Version

2.13.0

Current Behavior

When I try to render the default slot within the conditionally rendered parent element in the no-shadow component and the parent element is changed, the slot relocation algorithm loses the parent element reference and the slot element is not relocated (re-rendered) into the new parent element.

Expected Behavior

Slot element should be relocated to the new parent element.

System Info

No response

Steps to Reproduce

In the reproduction project:

  1. you will see the typography element is rendered correctly and the slot will be displayed within the "span" element in the "app-typography" component DOM structure
  2. when the user clicks on the "Toggle Element type" button, the handler function finds the typography element and changes its "element" attribute (which controls the rendered element tag of the slot's parent)
  3. then you will see the "span" element turns to the "p" element within the "app-typography" component DOM structure and the slot disappears (not relocated)

Code Reproduction URL

https://github.com/yigityuce/stencil-conditional-rendering-issue/commits/master

Additional Information

The issue might be here in the renderer (the old and new node tags checking)
https://github.com/ionic-team/stencil/blob/main/src/runtime/vdom/vdom-render.ts#L153

The goal is to follow the accessibility rules and the sementic web. I want to render the hX tags (h1, h2, ..., h6) correctly regarding the typography as Material UI does. (https://mui.com/material-ui/react-typography/#changing-the-semantic-element)

And the inspiration comes from the ionic-button component: https://github.com/ionic-team/ionic-framework/blob/main/core/src/components/button/button.tsx#L302

Activity

  1. johnjenkins commented on Dec 15, 2022

    @johnjenkins
    Contributor

    just tested - this bug will be fixed by this pr

  2. yigityuce commented on Dec 15, 2022

    @yigityuce
    ContributorAuthor

    just tested - this bug will be fixed by this pr

    thanks for your quick response!

    However, do you expect that this PR is gonna be merged soon? I see it is open since June 2021 😞 Do you think I can do anything to speed up this process?

  3. rwaskiewicz commented on Dec 15, 2022

    @rwaskiewicz
    Member

    Hey all,

    We're going to be working on slot-related fixes following the Stencil v3 release, which is slated to occur in January. Thanks!

  4. added
    Bug: Validated
    and removed on Dec 15, 2022
  5. rwaskiewicz commented on Jul 24, 2023

    @rwaskiewicz
    Member

    Potentially related #4284

  6. christian-bromann commented on Dec 11, 2023

    @christian-bromann
    Member

    Hey there 👋 we have released a Stencil version v4.8.2 with a fix for this issue. Make sure you enable it with the experimentalSlotFixes flag in your Stencil configuration. Let us know if you have any further question. Thanks for reporting!

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