Skip to content

Indeterminate checkbox doesn't change when changed from code #658

Closed
@stefanloerwald

Description

@stefanloerwald

Describe the bug

When Indeterminate="true" is set on a MatCheckbox, setting the value from code does not alter the visible state of the checkbox (it works fine when Indeterminate is false).

To Reproduce

<MatBlazor.MatCheckbox Indeterminate="true" Value="Value">Current value: @(Value == null ? "null" : Value.Value.ToString())</MatBlazor.MatCheckbox>
<MatBlazor.MatButton Label="Set to true" OnClick="() => Value = true" />
<MatBlazor.MatButton Label="Set to null" OnClick="() => Value = null" />
<MatBlazor.MatButton Label="Set to false" OnClick="() => Value = false" />

@code {
    public bool? Value { get; set; }
}

Click the buttons. The state of the checkbox doesn't change.

Blazorfiddle link
https://blazorfiddle.com/s/s7wd0j1x

Expected behavior
The checkbox state should change between clear, checked and indeterminate depending on the value of the nullable boolean.

Version is 2.6.2

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions