Feature request DialogService: Close handler to intercept and prevent closing // Make Close() virtual #523

Closed
opened 2026-01-29 17:38:40 +00:00 by claunia · 3 comments
Owner

Originally created by @Pmyl on GitHub (Aug 26, 2022).

Problem
When the user is filling a form in a modal dialog and accidentally presses the X (or overlay/cancel button), applications with good user experience should prompt a confirmation dialog to ask for confirmation.
Radzen DialogService doesn't have any "close handler" feature and cannot be used to achieve the above functionality.

Solution
Blazor has just recently added this feature to the NavigationManager by allowing to add/remove handlers that can intercept and cancel the navigation, a similar solution for the DialogService would allow creating "mistake safe" forms in dialogs.

Alternatives
There are 3 alternatives I've considered:

  • Tell everyone to not use modals to show forms
    • This would ruin the flow of some applications
  • Tell everyone to remove X and overlay dismiss, allowing full control on the dialog closing events
    • It's not good UX if an application has some dialogs with X/overlay dismiss and some other don't. it would confuse the users (it would confuse me for sure). Removing it for every dialog is not pretty
  • Make the Close method in DialogService virtual so that anyone can create a class MyDialogService : DialogService, override Close and implement their own intercept functionality
Originally created by @Pmyl on GitHub (Aug 26, 2022). **Problem** When the user is filling a form in a modal dialog and accidentally presses the X (or overlay/cancel button), applications with good user experience should prompt a confirmation dialog to ask for confirmation. Radzen DialogService doesn't have any "close handler" feature and cannot be used to achieve the above functionality. **Solution** Blazor has just recently added this feature to the NavigationManager by [allowing to add/remove handlers that can intercept and cancel the navigation](https://github.com/dotnet/aspnetcore/pull/42638), a similar solution for the DialogService would allow creating "mistake safe" forms in dialogs. **Alternatives** There are 3 alternatives I've considered: - Tell everyone to not use modals to show forms - This would ruin the flow of some applications - Tell everyone to remove X and overlay dismiss, allowing full control on the dialog closing events - It's not good UX if an application has some dialogs with X/overlay dismiss and some other don't. it would confuse the users (it would confuse me for sure). Removing it for every dialog is not pretty - Make the Close method in DialogService virtual so that anyone can create a `class MyDialogService : DialogService`, override Close and implement their own intercept functionality
Author
Owner

@Pmyl commented on GitHub (Aug 26, 2022):

@enchev hey I noticed you closed this issue without giving any reason, I'm sure it was a mistake, could you reopen it or give me a reason why it has been closed?

@Pmyl commented on GitHub (Aug 26, 2022): @enchev hey I noticed you closed this issue without giving any reason, I'm sure it was a mistake, could you reopen it or give me a reason why it has been closed?
Author
Owner

@akorchev commented on GitHub (Aug 26, 2022):

enchev closed this as completed in 77e3952849 4 hours ago

The issue was addressed in the linked commit.

@akorchev commented on GitHub (Aug 26, 2022): [enchev](https://github.com/enchev) closed this as [completed](https://github.com/radzenhq/radzen-blazor/issues?q=is%3Aissue+is%3Aclosed+archived%3Afalse+reason%3Acompleted) in https://github.com/radzenhq/radzen-blazor/commit/77e3952849474238ce7d5ea42b333edbc9f823d9 [4 hours ago](https://github.com/radzenhq/radzen-blazor/issues/588#event-7267096210) The issue was addressed in the linked commit.
Author
Owner

@Pmyl commented on GitHub (Aug 26, 2022):

I just noticed that, thank you @akorchev and @enchev !

@Pmyl commented on GitHub (Aug 26, 2022): I just noticed that, thank you @akorchev and @enchev !
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/radzen-blazor#523