MudExitPrompt: Add component#12287
Conversation
|
If we include this I think it should be a service, with components being reserved for stuff that's visible on the page to the user. Could you also add a short video showing it in use and tests if possible? |
|
Hardcoding translations is really not the way we'd want to move forward. We have a great localization service for that. Also, can't the popup be handled at the dialog service level? It should also have the ability to swap out with a custom one, like the |
|
|
@ScarletKuro The problem is that there is no way to catch and delay beforeunload as far as I know; this is handled by the browser directly. I could in theory show a custom popup on navigating away but I deliberately didn't do that as it would then show the browser dialog on close/reload and the MudDialog on navigation. This would probably confuse devs as their dialog is shown on some actions but not on all. Translations: Hardcoded, as I wanted both dialogs to look as similar as possible (it's just the translation of the browser dialog text). But I could also just add a string field with a default english text if that's prefered. |
|
I really like the usefulness of this functionality (I might need this in my SW) but I don't like the name. Here are some suggestions:
|
|
@henon As this also shows the dialog on tab close I would guess |
|
Okay, now with the video it’s clearer what kind of dialog it is. I thought it was just a popup in the middle of the screen. The localization can be solved in two ways:
|
We still can use some mocking to see if needed js calls are done on locationchange. |
|
|
Fixed the tests. Not sure why this was necessary: Context.Services.AddSingleton<NavigationManager>(s => s.GetRequiredService<BunitNavigationManager>());This shouldn’t have been required, since Btw: protected virtual async ValueTask DisposeAsyncCore()
{
if (!Disabled && _navigatedAway)
{
await DisableAsync();
}
}Shouldn’t the component always be disposed when |
|
Yeah, that is intentional; This would prevent the js from reacting to tab closed (that's also the reason the |
|
Ah okay, thanks. It will mostly likely live here in this mono repo, and to make things easier, docs will reference it directly. |
This PR adds a small component which can be used to require a confirmation before navigating away, closing or reloading.
