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 is immediately hidden if delay is omitted #4

Open
nirvana-msu opened this issue Jul 19, 2022 · 3 comments
Open

Toast is immediately hidden if delay is omitted #4

nirvana-msu opened this issue Jul 19, 2022 · 3 comments

Comments

@nirvana-msu
Copy link

The doc implies that delay argument can be omitted, and the toast will stay until manually dismissed:

Note: The final argument delay is omitable. If omitted, the toast will remain forever.

This does not seem to be the case... For example:

// This works, toast is shown and hidden after delay
$.toast({type: "error", title: "Test", content: "test", delay: 3000})

// This does not work - toast is hidden immediately after being shown (so it never even appears on screen)
$.toast({type: "error", title: "Test", content: "test"})

This piece of code runs right after the toast is shown:

setTimeout(function () {
    if (!paused) {
        $(`#${id}`).toast('hide');
    }
}, opts.delay);

If delay is omitted, opts.delay here is undefined, so setTimeout fires immediarely, and as paused is false, the toast is immediately hidden...

Even more confusingly, same code/bug is also present in the original library.. with the last commit years ago (.. how am I the first one discovering this?).

@nirvana-msu
Copy link
Author

Perhaps I am not the first one discovering. This fork has a bunch of fixes (diff), including disabling pauseDelayOnHover by default (which happens to mask the issue).

@nirvana-msu
Copy link
Author

Annoyingly, setting pauseDelayOnHover to false ends up not putting delay in the toast markout at all.... so whatever delay value you provide, it just uses Bootstrap default (5 seconds) instead.

@ABC-INTERACTIVE
Copy link

ABC-INTERACTIVE commented Nov 16, 2022

Try this fix

// (13) Deal with the delay
if ($.toastDefaults.pauseDelayOnHover && opts.delay) {

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