Skip to content

Commit 8ed1d31

Browse files
Tsvetomir-Hrdimodi
andauthored
Update predefined-dialog-beneath-modal-dialog-blazor.md (#3333)
* Update predefined-dialog-beneath-modal-dialog-blazor.md * polish --------- Co-authored-by: Dimo Dimov <961014+dimodi@users.noreply.github.com>
1 parent 87f641e commit 8ed1d31

File tree

1 file changed

+30
-37
lines changed

1 file changed

+30
-37
lines changed

knowledge-base/predefined-dialog-beneath-modal-dialog-blazor.md

Lines changed: 30 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,12 @@ ticketid: 1686792
1212
## Environment
1313

1414
<table>
15-
<tbody>
16-
<tr>
17-
<td>Product</td>
18-
<td>
19-
Dialog for Blazor
20-
</td>
21-
</tr>
22-
<tr>
23-
<td>Version</td>
24-
<td>Current</td>
25-
</tr>
26-
</tbody>
15+
<tbody>
16+
<tr>
17+
<td>Product</td>
18+
<td>Dialog for Blazor</td>
19+
</tr>
20+
</tbody>
2721
</table>
2822

2923
## Description
@@ -43,27 +37,29 @@ You can hide the close button of the main modal dialog via the `ShowCloseButton`
4337

4438
Or, you can apply a workaround to adjust the `z-index` of the predefined dialog.
4539

46-
### Using the `ShowCloseButton` Parameter
40+
### Set `ShowCloseButton` to `false`
4741

4842
Set the `ShowCloseButton` parameter of the main modal dialog to `false`, and move the confirmation logic to a button within the modal dialog. This ensures the predefined dialog does not overlap with the modal.
4943

50-
```razor
44+
````razor
5145
<TelerikDialog ShowCloseButton="false" @bind-Visible="@Visible">
52-
<!-- Modal Dialog Content -->
46+
<DialogContent>
47+
Dialog Content
48+
</DialogContent>
5349
<DialogButtons>
5450
<TelerikButton OnClick="@OnShowConfirm">ShowDialog</TelerikButton>
5551
</DialogButtons>
5652
</TelerikDialog>
5753
5854
@code {
5955
[CascadingParameter]
60-
private DialogFactory Dialogs { get; set; }
56+
private DialogFactory? Dialogs { get; set; }
6157
62-
private bool Visible { get; set; }
58+
private bool Visible { get; set; } = true;
6359
6460
private async Task OnShowConfirm()
6561
{
66-
bool isConfirmed = await Dialogs.ConfirmAsync("Are you sure?");
62+
bool isConfirmed = await Dialogs!.ConfirmAsync("Are you sure?");
6763
6864
if (isConfirmed)
6965
{
@@ -76,26 +72,28 @@ Set the `ShowCloseButton` parameter of the main modal dialog to `false`, and mov
7672
}
7773
}
7874
}
79-
```
75+
````
8076

81-
### Workaround: Adjust the `z-index` Dynamically
77+
### Adjust the `z-index` Dynamically
8278

83-
Use JavaScript to dynamically adjust the `z-index` of the predefined dialog. This ensures it appears above the modal dialog.
79+
Use JavaScript to dynamically adjust the `z-index` of the predefined dialog. This ensures it appears above the modal dialog. The approach targets the dialog wrapper using CSS selectors and modifies its `z-index` style.
8480

85-
#### JavaScript Code
81+
> This workaround relies on CSS selectors which may change in future updates of the Telerik theme. Use this approach with caution.
8682
87-
```javascript
88-
<script suppress-error="BL9992">
89-
function bringDialogToTop() {
90-
var dialogWrapper = document.querySelector(".k-window.k-dialog.k-alert.telerik-blazor").closest(".k-dialog-wrapper");
83+
>caption JavaScript
84+
85+
````javascript.skip-repl
86+
function bringDialogToTop() {
87+
var dialogWrapper = document.querySelector(".k-window.k-dialog.k-alert").closest(".k-dialog-wrapper");
9188
if (dialogWrapper) {
92-
dialogWrapper.style.zIndex = parseInt(dialogWrapper.style.zIndex) + 2;
93-
}
89+
dialogWrapper.style.zIndex = parseInt(dialogWrapper.style.zIndex) + 2;
9490
}
95-
</script>
96-
```
91+
}
92+
````
93+
94+
>caption Razor
9795
98-
```razor
96+
````razor
9997
@inject IJSRuntime js
10098
10199
<TelerikDialog Visible="@Visible" VisibleChanged="OnDialogClosingAsync">
@@ -145,12 +143,7 @@ Use JavaScript to dynamically adjust the `z-index` of the predefined dialog. Thi
145143
await base.OnAfterRenderAsync(firstRender);
146144
}
147145
}
148-
149-
This approach targets the dialog wrapper using CSS selectors and modifies its `z-index`.
150-
151-
#### Note
152-
153-
This workaround relies on CSS selectors which may change in future updates of the Telerik theme. Use this approach with caution.
146+
````
154147

155148
## See Also
156149

0 commit comments

Comments
 (0)