dotnet / dotnet/aspnetcore

InputCheckbox inside QuickGrid has 2 observed bugs: Stuck in Checked Position, and databinding not working as expected

Open
#67,308 0 comments 0 reactions 0 assignees View on GitHub
area-blazor
Dominant language
C#
Stars
38.4k
Forks
10.9k
Avg merge
2d 10h
Merged PRs (30d)
281

Description

### Is there an existing issue for this?

- [x] I have searched the existing issues

### Describe the bug

Consider this piece of code:

`




`

`

private void OnItemSelectionChanged() => FireItemSelectionChanged();

private void FireItemSelectionChanged()
=> SelectedItemsChanged.InvokeAsync(_rows.Where(x => x.Selected).Select(x => x.Plan).ToList());

`

Bug 1:
When OnItemSelectionChanged event handler runs, the row.Selected in the _rows collection still has the old value.
The handler should run "after" the row's state was changed.

Bug 2:
When checking the checkbox, and then try to uncheck it, the checkbox control is stuck in the "On/Check" position visually although rest of the code run correctly.

Here's what I did to fix these 2 problems (basically used the input html element and explicitly set the state on the row):

``

`
private void OnRowChanged(int planId, bool value)
{
var row = _rows.SingleOrDefault(x => x.Plan.Id == planId);
if (row is not null)
row.Selected = value;

FireItemSelectionChanged();
}
`

Attached is source code to the broken component.

[broken_viewprojectplans_component.txt](https://github.com/user-attachments/files/29113091/broken_viewprojectplans_component.txt)

### .NET Version

asp.net core Blazor .net 10

Contributor guide

Open the contributing guide

Research direction

Start with the attached broken component and reproduce both behaviors using InputCheckbox inside QuickGrid: the @bind-Value:after handler sees the old row.Selected value, and the checkbox remains visually checked after unchecking. Trace the binding and event flow, then verify that selection state, the callback values, and the rendered checkbox state all update correctly.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
frontend, web-dev
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.