Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nested Slots in Swiper Vue, are not printed in the right location #6574

Closed
5 of 6 tasks
Dru-S opened this issue Apr 13, 2023 · 0 comments
Closed
5 of 6 tasks

Nested Slots in Swiper Vue, are not printed in the right location #6574

Dru-S opened this issue Apr 13, 2023 · 0 comments
Labels

Comments

@Dru-S
Copy link

Dru-S commented Apr 13, 2023

Check that this is really a bug

  • I confirm

Reproduction link

https://codesandbox.io/p/sandbox/swiper-vue-default-forked-xf0jp2?file=%2Fsrc%2FApp.vue

Bug description

When using a Swiper inside a component, and the slots are passed from the parent component to the Swiper, they're not printed in the right slot.

Expected Behavior

Slots, used like that, inside a component:

<template v-slot:container-start><slot name="outer-container-start"></slot></template>
<template v-slot:container-end><slot name="outer-container-end"></slot></template>
<template v-slot:wrapper-start><slot name="outer-wrapper-start"></slot></template>
<template v-slot:wrapper-end><slot name="outer-wrapper-end"></slot></template>

should render in the right slot.

Actual Behavior

All slots passed from a parent component, are rendered in container-end, as per vue/get-children.js file:

...

if (slotName === 'default') slotName = 'container-end';
if (isFragment && vnode.children) {
        getSlidesFromElements(vnode.children, 'default');
}
...

Simply change

getSlidesFromElements(vnode.children, 'default');

to

getSlidesFromElements(vnode.children, slotName);

fixes the problem.

Swiper version

9.2.0 (and also lower)

Platform/Target and Browser Versions

All

Validations

  • Follow our Code of Conduct
  • Read the docs.
  • Check that there isn't already an issue that request the same feature to avoid creating a duplicate.
  • Make sure this is a Swiper issue and not a framework-specific issue

Would you like to open a PR for this bug?

  • I'm willing to open a PR
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant