radzenhq / radzen-blazor

Radzen Blazor is a set of 90+ free native Blazor UI components packed with DataGrid, Scheduler, Charts and robust theming including Material design and FluentUI.
https://www.radzen.com
MIT License
3.52k stars 785 forks source link

Close Notifications using the NotificationService #78

Closed Stjin closed 3 years ago

Stjin commented 3 years ago

Is your feature request related to a problem? Please describe. My issue is not related to a problem, however currently it is only possible to create and Notify a message without manually closing the notification programmatically. This can become a problem when you use the notification to permanently show a status for an async task (such as "Changing status..." or something) .It would be great to hide/close the notification programmatically.

Describe the solution you'd like I would like to see something like NotificationService.Close(message); or message.Close();

Describe alternatives you've considered I cannot think of any alternative as async (network) requests don't have a specific duration.

Additional context I feel like adding a .Close(); method is a basic functionality that would definitely improve the Notification component

enchev commented 3 years ago

Hey @Stjin,

NotificationService.Messages is ObservableCollection and if you execute Clear() all messages will be removed: https://github.com/radzenhq/radzen-blazor/blob/master/Radzen.Blazor/RadzenNotification.razor#L30

Stjin commented 3 years ago

Hey @Stjin,

NotificationService.Messages is ObservableCollection and if you execute Clear() all messages will be removed: https://github.com/radzenhq/radzen-blazor/blob/master/Radzen.Blazor/RadzenNotification.razor#L30

How did I miss that, thanks for your quick reply!

Stjin commented 3 years ago

@enchev I noticed NotificationService.Messages.Remove(message); is not removing the passed notification. Is this expected behaviour?