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 changes are not reflected in Swiper instance #4458

Closed
viters opened this issue Apr 20, 2021 · 7 comments
Closed

navigation changes are not reflected in Swiper instance #4458

viters opened this issue Apr 20, 2021 · 7 comments
Labels

Comments

@viters
Copy link

viters commented Apr 20, 2021

  • Swiper Version: 6.4.15
  • Platform/Target and Browser Versions: web

What You Did

Navigation changes are not recognized by swiper component. If you set navigation: false and later change to specific HTML element refs, it will not work, even after calling update on swiper instance.

Example: https://stackblitz.com/edit/react-ayg1t2?file=src%2FApp.js

Expected Behavior

When I change props, component does update accordingly.

Actual Behavior

I change navigation and nothing happens, even with forced update.

@viters viters added the React label Apr 20, 2021
@nolimits4web
Copy link
Owner

navigation nextEl, prevEl doesn't support refs, it accepts HTMLElements or string with CSS selector of elements.

@viters
Copy link
Author

viters commented Apr 20, 2021

@nolimits4web
I did not mean React Ref objects. Anyway, it does not matter what you pass to navigation, it is not the concern of this issue. The problem is that changing navigation does not update Swiper component.

@nolimits4web
Copy link
Owner

Check this thread #3855 maybe it has solution for you?

@viters
Copy link
Author

viters commented Apr 20, 2021

Sadly, it doesn't. Moreover, it contains workarounds, not bug fixes. Anway, I cannot call sliderInstance?.navigation?.update() when navigation is initially set to false. The bug is: "Swiper component does not react to changes to navigation prop". I believe the same bug applies to event listeners, although this issue is about navigation specifically.

@nolimits4web
Copy link
Owner

As you didn't provide live example, I have no idea what you are doing, but navigation.update() is for updating existing navigation, to create it navigation.init() should be called instead

@viters
Copy link
Author

viters commented Apr 20, 2021

I thought the bug is clear, but as you ask, I've added example.

but navigation.update() is for updating existing navigation, to create it navigation.init() should be called instead

I see no property on swiper that would inform whether navigation has been initialized or not.

nolimits4web added a commit that referenced this issue Apr 20, 2021
…ustom elements added after initialization

fixes #4458
@nolimits4web
Copy link
Owner

👆fixed, will be available with next update on a days

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

2 participants