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

Disable behavior for specific Links #102

Open
elC0mpa opened this issue Nov 21, 2024 · 1 comment
Open

Disable behavior for specific Links #102

elC0mpa opened this issue Nov 21, 2024 · 1 comment

Comments

@elC0mpa
Copy link

elC0mpa commented Nov 21, 2024

I have the following component which have a Link and inside it a Button. The button handler makes use of e.preventDefault() an e.stopPropagation().

      <Link
        href={`/product/${product.code}?currency=${selectedCurrency._id}&inventory=${selectedInventory._id}`}
      >
        <div className="h-[40px] bg-primary rounded-t-lg"></div>
        <div className="w-full h-[290px] relative">
          <Image
            src={product.imageUrl || PlaceHolderImage}
            alt={product.name}
            style={{ objectFit: "cover" }}
            quality={100}
            fill
          />
          {!!product.containedProducts?.length && <ProductCardKit />}
        </div>
        <div className="px-2 pt-3">
          <ProductCardInfo
            product={product}
            selectedCurrency={selectedCurrency!}
          />
          <Button
            variant="outlined"
            startIcon={<IconShoppingBag size={24} />}
            sx={{
              width: "100%",
              height: "56px",
              borderRadius: "8px",
              borderWidth: "2px",
              padding: "16px",
            }}
            onClick={addProductToCart}
          >
            <p className="text-button uppercase font-bold">Añadir a cesta</p>
          </Button>
        </div>
      </Link>

Even in this way the top loader behavior is triggered and it shows indefinitely, how can I avoid this?

@TranThanhTamBuu
Copy link

TranThanhTamBuu commented Nov 25, 2024

@elC0mpa This work for me

event.preventDefault();
event.nativeEvent.stopImmediatePropagation();

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

2 participants