sotsera / sotsera.blazor.toaster

A Toastr.js port to Blazor in pure .Net.
https://blazor-toaster.sotsera.com/
MIT License
130 stars 29 forks source link

Possible Feature #20

Closed enkodellc closed 5 years ago

enkodellc commented 5 years ago

I'm not sure if this is possible but might be worth a look to see we can integrate the toast into the the Validation Summary of a form. So instead of the Validation Summary showing up it would fire a Toast with the Control Label as the Title and the Validation Message would be the Toast Message.

https://docs.microsoft.com/en-us/aspnet/core/blazor/forms-validation?view=aspnetcore-3.0

Great work on the the Toast!

ghidello commented 5 years ago

Hi @enkodellc. I just read the ValidationSummary sources and at a first glance it should be possible to extend it to raise a toast when the validation status changes. How would you handle a form with errors on many fields? One toast for every field can became quickly overwhelming and currently a Toast message is html escaped and so it cannot be styled as a html list. Any ideas?

enkodellc commented 5 years ago

I thought I had read that as well. If it were me I would just queue up the toasts and run them all. I believe most people would have some additional UI validators on the fields themselves to change them Red or add an asterisk beside them. That would be really great if toaster / validator did that. Most likely already does. If you want I can try and help a bit. I can definitely help test.

ghidello commented 5 years ago

There's a new branch called form_validation with:

It works but probably it works too much :laughing: The event the component is listening right now is OnValidationStateChanged so a new aggregate toast or set of toasts will be fired whenever a field loses focus. A better approach would be to show the toasts only when the submit button is pressed probably using the OnValidationRequested event but I've not had a chance to figure out its usage.

What do you whink so far?

enkodellc commented 5 years ago

@ghidello great. I apologize I will not be able to test for a day or so. Sounds like though you are making it happen!

ghidello commented 5 years ago

Sorry for the long wait but I've been sidetracked on other stuff. Have you had a chance to test the approach and maybe play a bit with the css for displaying the message list?

ghidello commented 5 years ago

Closing for now. Feel free to reopen this issue if you still need this feature.