-
Notifications
You must be signed in to change notification settings - Fork 83
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
[notification] Add close/dismiss button #438
Comments
|
Right, this could be opt-in initially, and marked to be changed to opt-out in the next major version. |
Passing in the '0' duration will cause the notification to stay displayed; since there's no way for the user to close the notification without the close button, the notification pretty much stays around indefinitely (unless a close button is added manually by the programmer). Currently, the only way to make a persistent notification with a close button is this very very chatty code: final Notification notification = new Notification(new Span("An application error happened"));
notification.setDuration(0);
notification.setPosition(Notification.Position.TOP_CENTER);
notification.addThemeVariants(NotificationVariant.LUMO_ERROR, NotificationVariant.LUMO_PRIMARY);
final Button closeButton = new Button(new Icon(VaadinIcon.CLOSE));
closeButton.addThemeVariants(ButtonVariant.LUMO_ICON, ButtonVariant.LUMO_TERTIARY);
closeButton.addClickListener(e -> notification.close());
notification.add(closeButton);
notification.show(); |
Add a default close/dismiss button to all notifications (a new themable part), to avoid the need for application develpers to do that manually. It is considered a best practice to have an explicit dismiss button for notifications.
Add a new theme variant that the developer can use to opt-out of (hide) the default close/dismiss button.
Open questions:
The text was updated successfully, but these errors were encountered: