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

Navigation module "destroy" do not clean up HTML DOM elements for arrows #6672

Closed
5 of 6 tasks
neatbyte-vnobis opened this issue May 12, 2023 · 0 comments
Closed
5 of 6 tasks

Comments

@neatbyte-vnobis
Copy link

Check that this is really a bug

  • I confirm

Reproduction link

https://codesandbox.io/p/sandbox/swiper-manipulation-forked-zo75it?file=%2Findex.html%3A98%2C14

Bug description

We are trying to use a Swiper for dynamic slider with settings that are changing dynamically (in our case show/hide navigation arrows if user clicks a button/tougle).
So we are adding and removing Swiper attribute "navigation"="true".

It works well to add the navigation on button click (navigation arrow buttons appears and are working well).
But it is not working well when we are removing the "navigation"="true" attribute - navigation is not removed.
Even if we are destroying navigation via code swiper.navigation.destroy() - navigation arrow buttons are not clickable but still remain in shadow DOM as visible elements.

Here in Navigation module code need to clean up shadow dom elements on destroy:
https://github.com/nolimits4web/swiper/blob/master/src/modules/navigation/navigation.js#L126

Also after swiper.navigation.destroy() we need to manually do swiper.navigation.init() as without it adding "navigation"="true" again is not working. Is it smth expected for a Swiper?

Also looks like same issue is present for a pagination module (leftover shadow DOM elements):
see https://github.com/nolimits4web/swiper/blob/master/src/modules/pagination/pagination.js#L394

Expected Behavior

After removing Swiper attribute "navigation"="true" (or setting it to false) - navigation arrow buttons are removed from shadow DOM.

Actual Behavior

After removing Swiper attribute "navigation"="true" (or setting it to false) - there are leftover Shadow DOM elements for arrow buttons.

Swiper version

9

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
Projects
None yet
Development

No branches or pull requests

2 participants