Skip to content

Commit 599e514

Browse files
committed
DialogService.OpenAsync will not execute Radzen.openDialog() when options.ChildContent is set
Fix #717
1 parent 4205482 commit 599e514

File tree

4 files changed

+32
-8
lines changed

4 files changed

+32
-8
lines changed

Radzen.Blazor/DialogService.cs

-4
Original file line numberDiff line numberDiff line change
@@ -264,8 +264,6 @@ public void Dispose()
264264
CssClass = options != null ? $"rz-dialog-confirm {options.CssClass}" : "rz-dialog-confirm",
265265
};
266266

267-
await JSRuntime.InvokeAsync<string>("Radzen.openDialog", dialogOptions, Reference);
268-
269267
return await OpenAsync(title, ds =>
270268
{
271269
RenderFragment content = b =>
@@ -324,8 +322,6 @@ public void Dispose()
324322
CssClass = options != null ? $"rz-dialog-alert {options.CssClass}" : "rz-dialog-alert",
325323
};
326324

327-
await JSRuntime.InvokeAsync<string>("Radzen.openDialog", dialogOptions, Reference);
328-
329325
return await OpenAsync(title, ds =>
330326
{
331327
RenderFragment content = b =>

Radzen.Blazor/RadzenDialog.razor

-2
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@
1919
dialogs.Add(new Dialog() { Title = title, Type = type, Parameters = parameters, Options = options });
2020

2121
await InvokeAsync(() => { StateHasChanged(); });
22-
23-
await JSRuntime.InvokeAsync<string>("Radzen.openDialog", options, Service.Reference);
2422
}
2523

2624
public async Task Close(dynamic result)

Radzen.Blazor/Rendering/DialogContainer.razor

+30
Original file line numberDiff line numberDiff line change
@@ -174,4 +174,34 @@
174174
{
175175
Service.OnRefresh -= OnRefresh;
176176
}
177+
178+
protected override async Task OnAfterRenderAsync(bool firstRender)
179+
{
180+
await base.OnAfterRenderAsync(firstRender);
181+
182+
if (firstRender)
183+
{
184+
var options = Dialog.Options;
185+
186+
var dialogOptions = new DialogOptions()
187+
{
188+
Width = options != null ? !string.IsNullOrEmpty(options.Width) ? options.Width : "" : "",
189+
Height = options != null ? options.Height : null,
190+
Left = options != null ? options.Left : null,
191+
Top = options != null ? options.Top : null,
192+
Bottom = options != null ? options.Bottom : null,
193+
ShowTitle = options != null ? options.ShowTitle : true,
194+
ShowClose = options != null ? options.ShowClose : true,
195+
Resizable = options != null ? options.Resizable : false,
196+
Draggable = options != null ? options.Draggable : false,
197+
Style = options != null ? options.Style : "",
198+
AutoFocusFirstElement = options != null ? options.AutoFocusFirstElement : true,
199+
CloseDialogOnOverlayClick = options != null ? options.CloseDialogOnOverlayClick : false,
200+
CloseDialogOnEsc = options != null ? options.CloseDialogOnEsc : true,
201+
CssClass = options != null ? options.CssClass : "",
202+
};
203+
204+
await JSRuntime.InvokeAsync<string>("Radzen.openDialog", dialogOptions, Service.Reference);
205+
}
206+
}
177207
}

Radzen.Blazor/wwwroot/Radzen.Blazor.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -954,8 +954,8 @@ window.Radzen = {
954954
var lastDialog = dialogs[dialogs.length - 1];
955955

956956
if (lastDialog) {
957-
if (lastDialog.firstElementChild && lastDialog.firstElementChild.classList.contains('rz-html-editor')) {
958-
var editable = lastDialog.firstElementChild.querySelector('.rz-html-editor-content');
957+
if (lastDialog.querySelectorAll('.rz-html-editor-content').length) {
958+
var editable = lastDialog.querySelector('.rz-html-editor-content');
959959
if (editable) {
960960
var selection = window.getSelection();
961961
var range = document.createRange();

0 commit comments

Comments
 (0)