Skip to content

Conversation

gmpaliwal07
Copy link

What: Prevents the toast progress bar from pausing when tapped on mobile devices, ensuring the toast auto-closes as expected. Keeps the hover-to-pause behavior on desktop.

Why: Fixes issue #1217 where tapping a toast on mobile paused the progress bar, preventing auto-close.

How: Added isMobile utility to detect mobile devices. Updated useToast to skip pauseOnHover logic on mobile in both eventHandlers and onDragTransitionEnd.

Testing: Tested in the playground demo on mobile emulation (Chrome) and desktop. Confirmed the progress bar continues on mobile tap and pauses on desktop hover.

Fixes #1217

@gmpaliwal07
Copy link
Author

Hey @fkhadra can you just review and merge I have solved this issue and tested on the local machine too

Copy link

@NekoSakuraLucia NekoSakuraLucia left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM >-<

@gmpaliwal07
Copy link
Author

Can you please Merge it

@NekoSakuraLucia
Copy link

Can you please Merge it

Sorry, I can’t merge it myself. We’ll have to wait for the collaborator to do the merge. @gmpaliwal07

@Link2Twenty
Copy link

@fkhadra do you want touch taps to pause the toast?

If you don't I think the fix should be as simple as

https://github.com/fkhadra/react-toastify/blob/main/src/hooks/useToast.ts#L81-L96

becomes

function onDragTransitionEnd(e: React.PointerEvent<HTMLElement>) {
  const { top, bottom, left, right } = toastRef.current!.getBoundingClientRect();

  if (
    e.nativeEvent.pointerType !== 'touch' &&
    props.pauseOnHover &&
    e.clientX >= left &&
    e.clientX <= right &&
    e.clientY >= top &&
    e.clientY <= bottom
  ) {
    pauseToast();
  } else {
    playToast();
  }
}

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

Successfully merging this pull request may close these issues.

Toasters progress bar stops on mobile when clicked
3 participants