microsoft / fluentui-blazor

Microsoft Fluent UI Blazor components library. For use with ASP.NET Core Blazor applications
https://www.fluentui-blazor.net
MIT License
3.87k stars 376 forks source link

fix: SplashScreen is closable by pressing ESC key #1803

Closed emetrix closed 7 months ago

emetrix commented 7 months ago

🐛 Bug Report

SplashScreen is closable by pressing ESC key.

💻 Repro or Code Sample

The behaviour is reproducable in demo site: https://www.fluentui-blazor.net/SplashScreen or in the sample at https://github.com/emetrix/Samples.BlazorFluentUI-Splashscreen

🤔 Expected Behavior

A splashscreen for e.g. indicating long running tasks should not be closable by the user.

😯 Current Behavior

The SplashScreen closes when the Escape key is pressed by the user.

💁 Possible Solution

ignoring ESC or all key presses while a splashscreen is displayed ?

🔦 Context

I try to use a custom splashscreen during calculations and data access operations. Therefore the dialog should not be closable by the users.

🌍 Your Environment

vnbaaij commented 7 months ago

Hi Tobi,

See the example at https://www.fluentui-blazor.net/Dialog#customizeddialog for a dialog that cannot be closed/dismissed by using the 'Esc' key. I'm assuming this works for a Splash Screen as well (but not 100% sure).

Please test and let us know. Danke!

emetrix commented 7 months ago

Hi Vincent, thank you for your feedback. All dialog samples except Customized Dialog and Editable Dialog closes when the Esc key is pressed. But I can't see why the behaviour differs in the samples - or how to modiy it ?

vnbaaij commented 7 months ago

My first guess would be it is because of PreventDismissOnOverlayClick being set. I would need to look at the code to be sure. But not doing that now. Enjoying the ☀ for a bit!

emetrix commented 7 months ago

Just tried PreventDismissOnOverlayClick: For the SplashScreen I can see no difference at setting this to true or false ?

private async Task ShowLoadScreenAsync()
{
        parameters = new()
            {
                DialogType = DialogType.SplashScreen,
                PreventDismissOnOverlayClick = true,

                Content = new()
                {
                    DisplayTime = 0,
                    LoadingText = "Loading data..."
                },

                Width  = "300px",
                Height = "110px"
            };

        _dialog = await DialogService.ShowSplashScreenAsync<CustomLoadScreen>(parameters);
}
vnbaaij commented 7 months ago

Looking at this some more. Have not found the difference between this and the custom dialog yet either

dvoituron commented 7 months ago

We could add an option to prevent the user from closing the SplashScreen, but I don't find it disturbing that, by default, the ESC key can do this. This is also available in Office applications.

image

emetrix commented 7 months ago

I would be thankful if you could implement such an option/feature. In case of a splashscreen indicating a (long) running task closing the screen would lead to a white/blank screen until the task is finished - which I think would irritate users.

dvoituron commented 7 months ago

I agree. That could be an interesting feature.

dvoituron commented 7 months ago

1811 will fix this issue.

vnbaaij commented 7 months ago

I would be thankful if you could implement such an option/feature. In case of a splashscreen indicating a (long) running task closing the screen would lead to a white/blank screen until the task is finished - which I think would irritate users.

So there is a switch for it already: PreventDismissOnOverlayClick

It just wasn't used in the actual ialog calling function yet. With the fix from Denis this works now as expected.

emetrix commented 7 months ago

Thank you so much for your fast help and this awesome project in general !!!