Same dialog opening multiple times

Hello @Team

There has been a bug where the same dialog can be opened multiple times, one on top of the other. I was using a workaround where you always close a dialog before opening a new one, but in testing the bug was still happening when clicking multiple times a button that opens a dialog really fast.

This is reproduceable in the demo. Just click multiple times in any of the buttons and many dialogs will open.

Also there is another bug in this demo. After clicking the "Busy Dialog", every other dialog will start closing automatically as well.

This happens because the button will fire its click event as many times as the user clicks it. Not sure if this is a bug. Seems to work the same way with a regular <button>. If you don't want your users to click multiple times on a button you should probably disable them after the first click.

We will fix that soon! Thanks for reporting it.

The click event is working as it should indeed, but the dialog isn't in my opinion. Why would anyone want to open the same dialog on top of the other?

We have users that open a dialog from a dialog. We can't disable that.

Hey @kim,

I've updated the demo to illustrate how to disable the button to prevent the same dialog to be opened twice.

On my attempts the bug still occurs even after your fix.

This is how I was handling this before. It's not consistent and doesn't work with cascading dialogs.
image

I have just pushed a change which should hopefully address this issue. Basically it waits for the click event handler to return before firing a new one. My initial tests on the dialog page seem promising.

1 Like

Thanks for addressing this issue. I hope you can fix it for good.

I just uploaded a new version of Radzen.Blazor which contains that change (3.3.1). The online dialog demo seems to work fine - I wasn't able to open more than one dialog by clicking multiple times.

The whole problem is related to Blazor's architecture - a DOM event makes a web socket request to the server. Then before the first request has ended a second one is fired. This causes the Click event of the Button to fire more than once and as a result the dialog service opens more than one dialog. Once a dialog is open its overlay prevents further click events.

The fix uses a flag to prevent triggering the Click event of RadzenButton before the previous handler has finished.

1 Like

The flag is definitely working, I couldn't open multiple dialogs anymore.

I noticed something else too, that doesn't affect my app, but may impact on others'. The close event can be triggered multiple times too. Could result in a mess with cascading dialogs.

I can't seem to reproduce the Close event firing multiple times. There could be some demo which subscribes to OnClose but does not unsubscribe in Dispose. I will check if this is the case.

Nope, there is no OnClose which isn't unsubscribed. Here is what I test:

  1. I go to https://blazor.radzen.com/dialog
  2. I open all the dialogs and monitor the log. I don't see any duplicate close events being logged.

Try clicking multiple times the Yes/No button in the Confirm Dialog.

Another problem in the demo is that with the new fix, the busy dialogs are opening only once.