Skyleen77 / next-nprogress-bar

NProgress integration on Next.js compatible with /app and /pages folders
https://next-nprogress-bar.vercel.app
315 stars 24 forks source link

Progress bar running when Link has preventDefault() #55

Closed shivankacker closed 5 months ago

shivankacker commented 5 months ago

Example:

const [mouseDownTime, setMouseDownTime] = useState(0);

  const handleClick = (e: any) => {
    e.preventDefault();
    e.stopPropagation();
    // check if it was a click or a drag
    if (Date.now() - mouseDownTime < 100) {
      window.location.href = e.currentTarget.href;
    }
  };

  const handleMouseDown = (e: any) => {
    e.preventDefault();
    setMouseDownTime(Date.now());
  }
<Link
  href={"/"}
  draggable={false}
  onMouseDown={handleMouseDown}
  onClick={handleClick}
>
    Link
</Link> 

https://github.com/Skyleen77/next-nprogress-bar/assets/23238460/2c36c43d-b618-46ca-ac0f-755cd74550c9

Am I doing something wrong? Or is this an issue?

shivankacker commented 5 months ago

Closing this as this looks like a duplicate of https://github.com/Skyleen77/next-nprogress-bar/issues/52. That fixed the issue for me