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

SolidJS Swiper looses the state when changing any params #5862

Closed
6 tasks done
TiagoCavalcante opened this issue Jul 7, 2022 · 0 comments
Closed
6 tasks done

SolidJS Swiper looses the state when changing any params #5862

TiagoCavalcante opened this issue Jul 7, 2022 · 0 comments
Labels

Comments

@TiagoCavalcante
Copy link
Contributor

Check that this is really a bug

  • I confirm

Reproduction link

https://codesandbox.io/embed/upbeat-rain-fsj16g?fontsize=14&hidenavigation=1&theme=dark

Bug description

When you change the params of the swiper, it returns to the first slide, losing its state:

import { render } from "solid-js/web";

import "swiper/swiper-bundle.css";
import { Swiper, SwiperSlide } from "swiper/solid/swiper-solid";
import { Navigation, Pagination } from "swiper";
import { createSignal } from "solid-js";

const App = () => {
  const [pagination, setPagination] = createSignal(false);

  return (
    <>
      <button
        type="button"
        onClick={() => setPagination(current => !current)}
      >
        {pagination() ? "Disable pagination" : "Enable pagination"}
      </button>

      <Swiper
        modules={[Navigation, Pagination]}
        navigation
        pagination={pagination()}
      >
        <SwiperSlide>1</SwiperSlide>
        <SwiperSlide>2</SwiperSlide>
        <SwiperSlide>3</SwiperSlide>
        <SwiperSlide>4</SwiperSlide>
        <SwiperSlide>5</SwiperSlide>
        <SwiperSlide>6</SwiperSlide>
      </Swiper>
    </>
  );
};

render(App, document.getElementById("app"));

@nolimits4web I want to fix this, but I don't understand which part of the code is responsible to update the parameters, for example, ensuring mountSlider is only run once breaks the reactivity. It'd be nice if you could give me a hand here.

Expected Behavior

No response

Actual Behavior

No response

Swiper version

8.3.0

Platform/Target and Browser Versions

Linux Microsoft Edge 103

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