lwc icon indicating copy to clipboard operation
lwc copied to clipboard

Forwarding scoped slot does not map to the correct slot assignment

Open jmsjtu opened this issue 1 year ago • 2 comments

Description

When forwarding a scoped slot to another slot, the slot mapping is incorrect. The scoped slot will always be slotted into the default slot of the component.

Here's a stackblitz demo.

<template lwc:render-mode="light">
  <x-scoped-slot-child>
    <template lwc:slot-data="title">
      <h2>{title}</h2>
    </template>
  </x-scoped-slot-child>
</template>

// x-scoped-slot-parent
<template lwc:render-mode="light">
  <x-leaf>
    <!-- Note slot="foo" doesn't map to <slot name="foo"> in x-leaf -->
    <slot lwc:slot-bind={title} slot="foo"></slot>
  </x-leaf>
</template>

// x-scoped-slot-child

Notice in x-scoped-slot-child, slot="foo" on the slot element.

<template>
  <slot></slot>
  <slot name="foo"></slot>
</template>

// x-leaf

Inspecting the elements, the scoped slot is slotted into the default slot of x-leaf, ignoring the slot attribute in x-scoped-slot-child.

jmsjtu avatar Dec 05 '23 22:12 jmsjtu

cc @ravijayaramappa created an issue to track

jmsjtu avatar Dec 05 '23 22:12 jmsjtu

This issue has been linked to a new work item: W-14913824

git2gus[bot] avatar Jan 29 '24 18:01 git2gus[bot]

Fix with #3883

jmsjtu avatar Mar 13 '24 16:03 jmsjtu