Skip to content

$slots/useSlots reactivity breaks if same component with different content #6202

@Akryum

Description

@Akryum

Vue version

3.2.37 | @8edf4b3

Link to minimal reproduction

Repro 1
Repro 2

Steps to reproduce

Changing reactively the template for a slot with the same child component but with different content breaks reactivity of useSlots/$slots/setup context slots:

<script setup>
import { ref } from 'vue'
import Comp from './Comp.vue'
import Comp3 from './Comp3.vue'

const data = ref(0)
setInterval(() => {
  data.value++
}, 1000)
</script>

<template>
  <h1>{{ data }}</h1>
  <!-- BUG? Doesn't update properly -->
  <Comp3>
    <template v-if="data % 2 === 0" #actions>
      <Comp>
        <template #foo>
            {{ data }}
        </template>
      </Comp>
    </template>
    <template v-else #actions>
      <Comp>
        <template #foo>
        </template>
      </Comp>
    </template>
  </Comp3>
</template>

What is expected?

The computed calling slots.foo should be re-evaluated when the content changes.

What is actually happening?

It's not updated and the computed value is stuck.

System Info

No response

Any additional comments?

Related: Slots improvements RFC

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions