sevensidedmarble

sevensidedmarble

Flash messages should allow more than one of the same type

Hello all,

Apologies if this has been proposed before I guess, but I have a very simple one:

With the increasing importance of LV, I think the flash system that comes out of the box in Phoenix needs tweaking to allow more than one flash message of the same level at a time, so they could perform like toasts.

Thanks!

Most Liked

LostKobrakai

LostKobrakai

This has been asked for a few times. To me this always sounds like mixing up notifications with flash messages.

Flash messages are responses to the last action a user made.

Notifications are everything else that happens async while a user is online.

Generally I’m happy with a single message per type for the former task. The latter one however is something else and usually not just done by removing the single msg per type constraint, but also needs additional metadata of how long messages stay up, if they need to be explicitly closed or not, or they might even have follow up actions to be taken based on them, ….

Personally I think it would be much more useful to develop the latter in isolation from flash messages. E.g. they’ll likely never care for session storage and normal http.

The fact that flash messages in the default boilerplate look like notifications certainly doesn’t help though :sweat_smile:

christhekeele

christhekeele

Agreed. And in the world of round-trip HTTP requests, you only need one flash message of each type per page render because there is no opportunity to enqueue further actions.

I think it’s less true in LiveView projects, where user input is a continuous stream of events triggering asynchronous updates from the server. Multiple user actions can happen in a very short space of time, each deserving a “response to the last action a user made”. In a realtime scenario, you can stomp on your own feedback about earlier user actions if they happen to do two things that cause errors.

It’s a very frustrating user experience to look up at an error message only to see it get replaced by another before you can finish reading it. Allowing more than one flash message per type allows providing feedback on multiple successive actions.

sevensidedmarble

sevensidedmarble

For any following this, I started my own library as well. its very early but you can start to check it out if you want: GitHub - srcrip/live_toast: A beautiful drop-in replacement for the Phoenix Flash system. · GitHub

Where Next?

Popular in Proposals: Ideas Top

mikesax
On a Rails/Turbo site, the first page is typically loaded using http GET and then sockets are used navigate and replace HTML content for ...
New
marcandre
I notice that most events have bindings (e.g. phx-keyup) but not the input event. The input event is the preferred way to interact with ...
New
pinetops
LiveView is by far my favorite web tech, but a few things have been nagging me. So with all the fancy and ill advised elixir tricks I cou...
New
nocksock
LiveView has spoiled me and now I would LOVE to be able to write controllers like this: defmodule DeadViewWeb.ItemController do use De...
New
pelopo
Hi, Oficial docs got this wonderful feature to download the ePub version that we can chuck to our kindles and read it. Now we are in the...
New
AHBruns
So, LiveView 0.20 brought an async processing API which is a thin wrapper around tasks. It’s a very nice convenience, but the main thing ...
New
engineeringdept
In 2026 double submit/session tokens are no longer necessary to prevent against CSRF attacks. Instead, we can use the Sec-Fetch-Site head...
New
calebjosue
I am reading (Once more) the Phoenix web framework documentation, in the From endpoint to views section contained in the Request life-cyc...
New
Oliver
One common problem we face in constructing lists is that there is (AFAIK) no support for conditionally inserting members into list declar...
New
MatinDevs
Currently, there are ongoing discussions about enhancing Phoenix LiveView, particularly focusing on improving performance and user experi...
New

Other popular topics Top

aadeshere1
I have a another noob question about loop. Since elixir is immutable, while loop is not directly possible. total = 10 while total != 0 ...
New
Nvim
Anybody knows a comprehensive comparison of Django and Phoenix, thanks for the help. Where are they similar? Where do they differ the m...
New
greenz1
I have a phoenix application from which a user can download multiple(5-6) files of size 1MB. I couldn’t find anything related to sending ...
New
minhajuddin
I have seen a lot of code which picks the first element from a list using Enum.at(0) instead of List.first. Is there a reason why people ...
New
josevalim
Hi everyone, One of the features added to Elixir early on to help integration with Erlang code was the idea of overridable function defi...
New
nobody
Hi! In PHP: $_SERVER[‘SERVER_ADDR’] - in Elixir? Searched the docs for ip address and the web, no good results. Thanks!
New
jason.o
In the code below, if the create action is not set to accept “extra_key” as an input, it errors out with a message shown above. Is there ...
New
komlanvi
Hi everyone, I was playing with phoenix liveView but I run into an issue. I have a form and want to validate each input text when the te...
New
Qqwy
Update: How to use the Blogs & Podcasts section You can post links to your blog posts or podcasts either in one of the Official Blog...
3271 127089 1222
New
dokuzbir
I want to highlight html closing tags when i click a html tag. That works in .html files but doesnt work for html.eex templates. How can...
New

Latest on Elixir Forum

Elixir Forum

We're in Beta

About us Mission Statement