Repository navigation
Conversation
|
Thanks for your PR, @Yuvan111. Someone from the team will get assigned to your PR shortly and we'll get it reviewed. |
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
The null marker can become incorrect after attribute overrides, and null-bound selections may render incorrectly when the null option is not first.
Get a fresh assessment by requesting another Copilot review.
Review effort: Lite
Findings: 1
Open (1)
What changed in this PR
Adds null-preserving binding for @null options in single-select elements using a DOM marker and JavaScript event handling.
Changes:
- Emits marker attributes for null option values.
- Converts marked selections back to
null. - Adds component, render-tree, and E2E coverage.
| File | Summary |
|---|---|
src/Components/Web.JS/src/Rendering/Events/EventTypes.ts |
Handles marked single-select values. |
src/Components/test/testassets/BasicTestApp/SelectNullableOptionsComponent.razor |
Adds nullable select scenarios. |
src/Components/test/testassets/BasicTestApp/Index.razor |
Registers the test component. |
src/Components/test/E2ETest/Tests/FormsTest.cs |
Adds browser binding coverage; one nit remains regarding the non-null-to-null transition test. |
src/Components/Components/test/Rendering/RenderTreeBuilderNullableTest.cs |
Tests generated nullable-option frames. |
src/Components/Components/src/Rendering/RenderTreeBuilder.cs |
Has a critical marker override issue, a moderate initial-selection issue, and a documentation nit. |
💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.
There was a problem hiding this comment.
Written with GitHub Copilot (AI), which did the code reading and the local test runs described below ("I" refers to those runs). Posted by PureWeen.
Re-checked at 159d050. The stale-marker cleanup from the earlier rounds looks good: the tests fail as expected when I mutate the cleanup code.
Two things from the earlier review are still there at this head, and I reproduced both with small tests:
- Multi-select: only a direct
select[multiple] > optionis handled. Options inside anoptgroup, aRenderFragment, or a component (includingInputSelect<T[]>) still emit the marker. datalist: options wrapped in a render region still emit the marker.
There's also a new point on the behavior change itself, inline.
I didn't run the E2E tests, and I only checked the EventTypes.ts change with a small node script that mirrors the function, not the shipped bundle.
|
Looks like this PR hasn't been active for some time and the codebase could have been changed in the meantime. |

[Blazor] Preserve null values for in single select binding
Description
This change preserves the distinction between
nulland an empty string when binding a nullable value to a single<select>.When an
<option value="@null">belongs to a single-select element, Blazor renders:valueattribute because the DOM cannot represent a null option value.data-blazor-null-optionmarker identifying the option as representingnull.The change-event handler recognizes this marker and reports
nullto .NET instead of"". A property such asstring?therefore receivesnulldirectly without requiring manual conversion from an empty string.Html Output:
Preserving existing fallback behavior
The null marker is emitted only for options belonging to a single
<select>.Options outside that scope retain their existing browser text-content fallback:
<select multiple>.<datalist>.<optgroup>under<select multiple>.RenderFragmentunder<select multiple>or<datalist>.Scope and limitations
Tests
Added unit and browser tests covering null options in single-selects, multi-selects, datalists, optgroups, and render fragments, including duplicate attributes and case-insensitive HTML names.
Fixes #23934