Reputation: 826
I am trying to show the users warnings/errors Notifications with duration(0) and I expected the notifications to close when users click on them but nothing happens, there is no way to make these notifications disappear. How it suppose to work when setting the duration to zero? I had this problem almost a year ago, there is an old post in Vaadin's forum but the issues on Github were deleted
Upvotes: 1
Views: 481
Reputation: 1923
You can call notification.close()
to close it programmatically.
Button closeButton = new Button("Close");
Notification notification = new Notification(new HorizontalLayout(new Span("Hello!"), closeButton));
notification.setDuration(0);
closeButton.addClickListener(click -> notification.close());
notification.open();
Upvotes: 3