put_flash doesn't close unless I press close button.
Environment
- Elixir version (elixir -v): ~> 1.14
- Phoenix version (mix deps):~> 1.7.2
- Phoenix LiveView version (mix deps): ~> 0.19.2
- Operating system: Windows 11
- Browsers you attempted to reproduce this bug on (the more the merrier): Chrome and Edge
Actual behavior
Currently the put_flash method only accepts three parameters
put_flash(socket, :info, "It worked!")
So we can't make to close automatically after sometimes and we need to click the close button.
Expected behavior
It is better to have an option for making it to close after some times.
Hi @Erfan1995,
closing a flash is out of scope for LV itself, because it can be implemented quite easily in your application. LV supports the special lv:clear-flash event and you can use this together with a minimal client-side hook to automatically close the flash. For an example, see the LiveBeats application:
https://github.com/fly-apps/live_beats/blob/ac9780472e7019af274110a1cf71250a8d40c986/lib/live_beats_web/components/core_components.ex#L83
https://github.com/fly-apps/live_beats/blob/ac9780472e7019af274110a1cf71250a8d40c986/assets/js/app.js#L29-L40
@SteffenDE Thank you so much for clarifications.