Open fabyeah opened 2 years ago
Even just an option to disable the feature would be helpful 🙏
What version of notistack are you using @fabyeah ? v2 or v3? I can publish an update to v3
I'm using v2.
But an update to v3 is better than nothing, guess I could upgrade.
I also need this exact functionality removed or the ability to disable it. Thank you.
For anyone having same need, this is possible bypass:
/**
* Custom hook which overrides default functionality to pause snackbar close timer when mouse is hovered over it, by ignoring the mouse.
*/
export const useSnackbar = () => {
const { enqueueSnackbar: enqueueSnackbarFn } = useSnackbarFn()
const enqueueSnackbar = (message: string, options: OptionsObject) => {
const snackbarOptions = options || {}
snackbarOptions.SnackbarProps = {
...snackbarOptions.SnackbarProps,
style: { pointerEvents: 'none' },
}
enqueueSnackbarFn(message, snackbarOptions)
}
return { enqueueSnackbar }
}
However this doesn't solve snackbar staying on page forever when web broser is de-focused.
how can i prevent snackbar staying forever when web broser is de-focused?
@Bonfims
how can i prevent snackbar staying forever when web broser is de-focused?
You can use the disableWindowBlurListener
flag. See api reference
Currently the auto hide timer of the snackbar pauses when a user interacts with a snackbar and resets when the user stops interacting.
I'd argue that this is detrimental behavior. I don't see many use cases where this behavior is expected or helpful except maybe when someone is selecting and copying text from the snackbar. The much more frequent action of pressing a button only takes a fraction of a second and doesn't require a timeout imho. If it is necessary to pause the timer, that just means the developer failed in allotting enough time or keeping the text short and simple. Also moving the mouse into the snackbar on desktop or tapping it on mobile is not an intuitive action that users know and understand will stop the bar from disappearing.
On the other hand this feature is cause to frequent irritation of my users, as on mobile users will often try to swipe away purely informational snackbars without action buttons and then realize that that doesn't work (feature not implemented yet: https://github.com/iamhosseindhv/notistack/issues/281, https://github.com/iamhosseindhv/notistack/issues/138), and worse: the snackbar now for some reason doesn't disappear (until they tap outside, but often they will only scroll, which doesn't reset the timer). https://github.com/iamhosseindhv/notistack/issues/422 As the swiping away of notifications is an instinctual gesture, most affected users will not make the connection and just wonder why sometimes the snackbars go away and sometimes they stay around forever.
To fix this, I would suggest to simply remove the pause mechanism.