[Vuejs]-Why does this activator text disappear when treating slot as scoped slot?

0👍

Putting ="{on}" on the end will change the slot usage from a normal slot to a scoped slot. I’m not sure why you think the activator slot for v-list-group can be used as a scoped slot, nothing I’ve found in the documentation suggests that it supports this.

If we take a look at the code for v-list-group we see this:

https://github.com/vuetifyjs/vuetify/blob/db84347f242fe73288b72c7e72a1af04b09c9434/packages/vuetify/src/components/VList/VListGroup.ts#L157

activator is being accessed as a normal slot, via this.$slots.activator. This will only work if you use a normal slot.

Contrast that with other components, such as v-menu. The v-menu component also has an activator slot but it supports using it as either a normal slot or a scoped slot.

https://github.com/vuetifyjs/vuetify/blob/db84347f242fe73288b72c7e72a1af04b09c9434/packages/vuetify/src/components/VMenu/VMenu.ts#L435

Note how this explicitly references both this.$slots.activator and this.$scopedSlots.activator. In this case the actual inclusion of this slot happens in the activatable mixin:

https://github.com/vuetifyjs/vuetify/blob/db84347f242fe73288b72c7e72a1af04b09c9434/packages/vuetify/src/mixins/activatable/index.ts#L82

You’ll notice that this does support an on value being passed to the scoped slot. There’s a helper being used here called getSlot that smoothes over the differences between normal and scoped slots:

https://github.com/vuetifyjs/vuetify/blob/db84347f242fe73288b72c7e72a1af04b09c9434/packages/vuetify/src/util/helpers.ts#L477

None of this applies to v-list-group, which just supports a normal slot.

Leave a comment