Skip to content

Commit

Permalink
[Dialog] Fix regression, see details in microsoft#2542 (microsoft#2568)
Browse files Browse the repository at this point in the history
* Fix microsoft#2542 by not including Instance.ontent in hash code method.

* Fix issue by adding Visible to DialogParameters. Dialog Hide/Show methods will now set Visible value. Provider will only render dialog if Visible is true.
  • Loading branch information
vnbaaij authored and dannyldj committed Sep 26, 2024
1 parent 19a4f71 commit 163927c
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3333,6 +3333,11 @@
outside the dialog. Defaults to false.
</summary>
</member>
<member name="P:Microsoft.FluentUI.AspNetCore.Components.DialogParameters.Visible">
<summary>
Gets or sets if a dialog is visible or nt (Hidden)
</summary>
</member>
<member name="P:Microsoft.FluentUI.AspNetCore.Components.DialogParameters.PreventScroll">
<summary>
Prevents scrolling outside of the dialog while it is shown.
Expand Down
4 changes: 3 additions & 1 deletion src/Core/Components/Dialog/FluentDialog.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ protected override async Task OnAfterRenderAsync(bool firstRender)
public void Show()
{
Hidden = false;
Instance.Parameters.Visible = true;
RefreshHeaderFooter();
}

Expand All @@ -174,7 +175,8 @@ public void Show()
public void Hide()
{
Hidden = true;
RefreshHeaderFooter();
Instance.Parameters.Visible = false;
//RefreshHeaderFooter();
}

/// <summary>
Expand Down
5 changes: 4 additions & 1 deletion src/Core/Components/Dialog/FluentDialogProvider.razor
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@
{
@foreach (DialogReference dialog in _internalDialogContext.References)
{
<FluentDialog @key="@dialog.GetKey()" Id="@dialog.Id" Instance="@dialog.Instance" Data="@dialog.Instance.Content" @ondialogdismiss=OnDismissAsync />
if (dialog.Instance.Parameters.Visible)
{
<FluentDialog @key="@dialog.GetKey()" Id="@dialog.Id" Instance="@dialog.Instance" Data="@dialog.Instance.Content" @ondialogdismiss=OnDismissAsync />
}
}
}
}
9 changes: 7 additions & 2 deletions src/Core/Components/Dialog/Parameters/DialogParameters.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@ public class DialogParameters : ComponentParameters, IDialogParameters
/// </summary>
public bool PreventDismissOnOverlayClick { get; set; } = false;

/// <summary>
/// Gets or sets if a dialog is visible or not (Hidden)
/// </summary>
public bool Visible { get; set; } = true;

/// <summary>
/// Prevents scrolling outside of the dialog while it is shown.
/// </summary>to use
Expand Down Expand Up @@ -87,7 +92,7 @@ public class DialogParameters : ComponentParameters, IDialogParameters
/// <summary>
/// Gets or sets the height of the dialog. Must be a valid CSS height value like "600px" or "3em"
/// Only used if Alignment is set to "HorizontalAlignment.Center"
/// </summary>
/// </summary>
public string? Height { get; set; }

/// <summary>
Expand Down Expand Up @@ -121,7 +126,7 @@ public class DialogParameters : ComponentParameters, IDialogParameters
internal bool ShowPrimaryAction => !string.IsNullOrEmpty(PrimaryAction);

/// <summary>
/// Gets whether the secondary button is displayed or not. Depends on SecondaryAction having a value.
/// Gets whether the secondary button is displayed or not. Depends on SecondaryAction having a value.
/// </summary>
internal bool ShowSecondaryAction => !string.IsNullOrEmpty(SecondaryAction);

Expand Down
1 change: 1 addition & 0 deletions src/Core/Components/Dialog/Parameters/IDialogParameters.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ public interface IDialogParameters
DialogType DialogType { get; set; }
bool PreventScroll { get; set; }
bool PreventDismissOnOverlayClick { get; set; }
bool Visible { get; set; }
EventCallback<DialogResult> OnDialogResult { get; set; }
EventCallback<DialogInstance> OnDialogClosing { get; set; }
EventCallback<DialogInstance> OnDialogOpened { get; set; }
Expand Down

0 comments on commit 163927c

Please sign in to comment.