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

Toast-timing is very inconsistent. #33906

Closed
Glitchy-Tozier opened this issue May 9, 2021 · 8 comments · Fixed by #37590
Closed

Toast-timing is very inconsistent. #33906

Glitchy-Tozier opened this issue May 9, 2021 · 8 comments · Fixed by #37590
Labels

Comments

@Glitchy-Tozier
Copy link

Glitchy-Tozier commented May 9, 2021

Before opening:

Toast-timing is very inconsistent.

Sometimes it's the regular delay (for example 10 seconds), but sometimes the toast just disappears way quicker.

  • Operating system and version: Linux Mint 20.1 Cinnamon
  • Browser and version: Firefox
  • I'm not sure how to compile that code into a test-case but I took a screen capture:
BootstrapToasts.mp4
@alpadev
Copy link
Contributor

alpadev commented May 10, 2021

I think we need to clear the timeout in the hide() method as well. 🤔

@Glitchy-Tozier
Copy link
Author

Probably something like this.

The way i now got around this issue was by making the Toast a global variable in JS and then always doing toast.dispose() before showing it again.

@GeoSot
Copy link
Member

GeoSot commented May 11, 2021

@RyanBerliner any opinion on this, as you recently had a look on toast.js?

@RyanBerliner
Copy link
Contributor

I don't believe clearing the timeout in the hide method would fix this issue (though it certainly wouldn't hurt), because the timeout is already being cleared in the show method. This looks to be the same bug that was fixed with #31155 - so I'd first recommend checking if version v5.0.0-alpha2 or later is being used.

@Glitchy-Tozier
Copy link
Author

I used the version recommended in the bootstrap-dokumentation.

No idea whether that's tha alpha or not though.

@alpadev
Copy link
Contributor

alpadev commented May 12, 2021

I don't believe clearing the timeout in the hide method would fix this issue (though it certainly wouldn't hurt), because the timeout is already being cleared in the show method. This looks to be the same bug that was fixed with #31155 - so I'd first recommend checking if version v5.0.0-alpha2 or later is being used.

I agree, this shouldn't happen. In the video the OP dismissed the toast so I considered the problem is with hide() not clearing the timeout. But looks like the problem in general is when the click handler looks something like this:

button.addEventListener('click', () => {
  const toast = new bootstrap.Toast(toastEl);
  toast.show();
});

Hard to tell because we don't know what the code looked like, but

The way i now got around this issue was by making the Toast a global variable in JS and then always doing toast.dispose() before showing it again.

suggests the OP used a code similiar to my example. In that case the timeout may not be cleared and could overlap, thus result in a behaviour like in that video.

@Glitchy-Tozier
Copy link
Author

@alpadev Yep, that's pretty much what I did.

@AucT
Copy link
Contributor

AucT commented Dec 6, 2022

if you still need a fix, I've posted here #37577 (comment)

@AucT AucT mentioned this issue Dec 6, 2022
10 tasks
@mdo mdo closed this as completed in #37590 Jan 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
No open projects
Status: Done
Development

Successfully merging a pull request may close this issue.

5 participants