Flash message to disappear after 5 seconds?

Copy from what I wrote on bluesky.

A simple solution can be:

Putting the following on the <.flash> core component

phx-mounted={JS.dispatch("myapp:auto-clear", detail: %{timeout: 5000, attr: "phx-click"})}

and this JS in app.js

window.addEventListener("myapp:auto-clear", (e) => {
  let el = e.target;
  setTimeout(() => liveSocket.execJS(el, el.getAttribute(e.detail.attr)), e.detail.timeout);
});