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

autoHideDuration option doesn't work #267

Closed
lukawski opened this issue May 13, 2020 · 3 comments
Closed

autoHideDuration option doesn't work #267

lukawski opened this issue May 13, 2020 · 3 comments

Comments

@lukawski
Copy link

lukawski commented May 13, 2020

Expected Behavior

According to docs - Set autoHideDuration to 'undefined' if you don't want snackbars to automatically close - snackbar should not be closed automatically when autoHideDuration is set to undefined.

Current Behavior

Snackbar closes automatically after 5000 ms when autoHideDuration is set to undefined. SnackbarProvider.tsx - here you can see condition which decides what to set in snack.autoHideDuration. It's using || operator so when this prop is undefined it'll fallback to 5000. Perhaps this condition could be changed so it checks for undefined explicitly. Or maybe docs needs to be update if it's desired behavior? I know about persist option but currently docs are a bit misleading.

Steps to Reproduce

Link: https://codesandbox.io/s/serene-mccarthy-olvk4?file=/MessageButtons.js:1261-1276

  1. Call enqueueSnackbar with autoHideDuration set to undefined
enqueueSnackbar('Example message', { autoHideDuration: undefined })

Context

I want my snackbar not to be closed automatically but manually.

Your Environment

Tech Version
Notistack v0.9.13
React 16.3.1
Browser Google Chrome Version 81.0.4044.138 (Official Build) (64-bit)

Thanks for great library, it's really useful and I really enjoy using it!

iamhosseindhv added a commit that referenced this issue May 17, 2020
* Fixes #267 - Allow autoHideDuration of null

* Update CHANGELOG

* 0.9.16
@iamhosseindhv
Copy link
Owner

iamhosseindhv commented May 17, 2020

Thanks @lukawski .

Docs have been updated. You can pass null to stop snackbars from getting dismissed automatically.

Fix is available in v0.9.16

@lukawski
Copy link
Author

Thanks a lot.

@haimengzhang
Copy link

Setting persist=true in options doesn't work. The notification still gets dismissed after some durations (10 seconds). Is this a bug?

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

3 participants