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

Carousel.Slide x.clickAllowed is not a function #4174

Closed
SomiDivian opened this issue May 2, 2023 · 8 comments
Closed

Carousel.Slide x.clickAllowed is not a function #4174

SomiDivian opened this issue May 2, 2023 · 8 comments

Comments

@SomiDivian
Copy link

What package has an issue

@mantine/carousel

Describe the bug

"@mantine/carousel": "^6.0.9",
"embla-carousel-react": "^8.0.0-rc01"

Error

CarouselSlide.tsx:51 Uncaught TypeError: _a2.clickAllowed is not a function

What version of @mantine/hooks page do you have in package.json?

6.0.9

If possible, please include a link to a codesandbox with the reproduced problem

No response

Do you know how to fix the issue

None

Are you willing to participate in fixing this issue and create a pull request with the fix

None

Possible fix

No response

@rtivital
Copy link
Member

rtivital commented May 2, 2023

use embla-carousel-react 7.x instead of 8.x

@davidjerleke
Copy link

Hi!

Just adding my two cents. The release notes for v8 state that clickAllowed has been removed and is now handled automatically. I don’t think downgrading Embla is a future proof solution but rather band aid for now.

@rtivital
Copy link
Member

rtivital commented May 3, 2023

Yes, it will be fixed in @mantine/carousel once embla 8.0.0 is out, for now, it is required to use 7.0

@davidjerleke
Copy link

I understand. Thanks for the prompt reply 👍🏻.

Cheers

@yunusirmak
Copy link

yunusirmak commented May 9, 2023

You can also avoid this issue by giving

        onClick={(e) => {
          e.stopPropagation();
        }}

to your carousel slide items. This fixes the issue without downgrading the package.

Here is my full code for reference:

  const slides = images.map((url) => (
    <Carousel.Slide key={url}>
      <Image
        onClick={(e) => {
          e.stopPropagation();
        }}
        src={url}
        width="100%"
        height={carouselHeight}
        style={{ objectFit: "cover" }}
      />
    </Carousel.Slide>
  ));

@ejixxer999
Copy link

how do I got down to v7 ?

@GCMO
Copy link

GCMO commented Jul 12, 2023

You can also avoid this issue by giving

        onClick={(e) => {
          e.stopPropagation();
        }}

to your carousel slide items. This fixes the issue without downgrading the package.

Here is my full code for reference:

  const slides = images.map((url) => (
    <Carousel.Slide key={url}>
      <Image
        onClick={(e) => {
          e.stopPropagation();
        }}
        src={url}
        width="100%"
        height={carouselHeight}
        style={{ objectFit: "cover" }}
      />
    </Carousel.Slide>
  ));

You can also avoid this issue by giving

        onClick={(e) => {
          e.stopPropagation();
        }}

to your carousel slide items. This fixes the issue without downgrading the package.

Here is my full code for reference:

  const slides = images.map((url) => (
    <Carousel.Slide key={url}>
      <Image
        onClick={(e) => {
          e.stopPropagation();
        }}
        src={url}
        width="100%"
        height={carouselHeight}
        style={{ objectFit: "cover" }}
      />
    </Carousel.Slide>
  ));

THANK YOU! That worked at least on the Carousel Images.
However if the user clicks outside the images (in the slider, or title above the images), the error shows up again.
Any recommendations?

@rtivital
Copy link
Member

Fixed in 6.0.17 – clickAllowed is no longer called

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants