Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix single select bug regarding item list updates #1267

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion Material.Blazor/Foundation/ComponentFoundation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,12 @@ public abstract class ComponentFoundation : ComponentBase, IDisposable
private protected ConditionalCssClasses ConditionalCssClasses { get; } = new ConditionalCssClasses();


/// <summary>
/// Allows <see cref="OnAfterRenderAsync(bool)"/> to run for the next render only.
/// </summary>
private protected bool AllowNextOnAfterRenderAsync { get; set; } = false;


/// <summary>
/// The concurrent queue for javascript interop actions.
/// </summary>
Expand Down Expand Up @@ -328,10 +334,12 @@ protected sealed override void OnAfterRender(bool firstRender)
/// </summary>
protected override Task OnAfterRenderAsync(bool firstRender)
{
if (firstRender)
if (firstRender || AllowNextOnAfterRenderAsync)
{
try
{
AllowNextOnAfterRenderAsync = false;

if (ParentDialog != null && !ParentDialog.HasInstantiated)
{
ParentDialog.RegisterLayoutAction(this);
Expand Down
4 changes: 3 additions & 1 deletion Material.Blazor/Foundation/InputComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ public abstract class InputComponent<T> : ComponentFoundation
///// </summary>
private bool AllowNextRenderOnce { get; set; } = false;


/// <summary>
/// Gets a string that indicates the status of the field being edited. This will include
/// some combination of "modified", "valid", or "invalid", depending on the status of the field.
Expand All @@ -106,9 +107,10 @@ private protected void AllowAllRenders()

#region AllowNextRender

private protected void AllowNextRender()
private protected void AllowNextRender(bool allowNextOnAfterRenderAsync = false)
{
AllowNextRenderOnce = true;
AllowNextOnAfterRenderAsync = allowNextOnAfterRenderAsync;
}

#endregion
Expand Down
2 changes: 1 addition & 1 deletion Material.Blazor/Foundation/SingleSelectComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ protected override async Task OnParametersSetAsync()
}
}

AllowNextRender();
AllowNextRender(true);
await InvokeAsync(StateHasChanged).ConfigureAwait(false);
}
}
Expand Down
19 changes: 19 additions & 0 deletions ReleaseNotes.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,25 @@ title: ReleaseNotes
---
# Release Notes

#### [5.1.4](https://github.com/Material-Blazor/Material.Blazor/tree/5.1.4)

Released 2024-02-29

**Updates**
- Fixed bug in single select components where updates to the item list would not allow items added to the list to be selected.

**New components**

**New features**

**Breaking Changes**

**Deprecated Components**

**Known issues**

<br />

#### [5.1.3](https://github.com/Material-Blazor/Material.Blazor/tree/5.1.3)

Released 2024-02-21
Expand Down
Loading