mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-24 20:36:49 +00:00
We currently have two mechanisms to display flash messages. The old one through AngularJS and the new one with StimulusReflex. The AngularJS directive showed flashes for 10 seconds. The StimulusReflex controller showed them only for 3 seconds. But any time based disappearance of error messages is problematic. There's important information in there and some error messages can be long. It's also possible that a request takes a while, the user leaves the computer and comes back later. If we hide the flash automatically then the user may have no idea what went wrong. They may even think that everything is fine and their order went through. I removed the time-based removal of flash messages from the new StimulusReflex controller to address this problem. But I didn't touch the AngularJS directive because it will be removed anyway. There may also be many more messages that could be annoying if they didn't disappear, for example a simple "login successful". I personally think that flash messages that are not important to keep, don't need to be shown in the first place. The best UX makes the success obvious on the page. And success should be assumed.
12 lines
234 B
JavaScript
12 lines
234 B
JavaScript
import { Controller } from "stimulus";
|
|
|
|
document.addEventListener("turbolinks:before-cache", () =>
|
|
document.getElementById("flash").remove()
|
|
);
|
|
|
|
export default class extends Controller {
|
|
close() {
|
|
this.element.remove();
|
|
}
|
|
}
|