Repository navigation
Fix Inconsistent behavior occurs when using @bind and @bind-value in input date type - #67310
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes inconsistent <input type="date"> editing behavior in Blazor when using @bind/@bind-value with date/time types by avoiding disruptive re-renders during segmented date entry and aligning formatted null output with what browsers report for empty date inputs.
Changes:
- Adjusts binder empty-string handling to avoid resetting date/time values to invalid defaults while users are editing.
- Updates
BindConverterformatting for nullable date/time types to return""(instead ofnull) so renderedvaluestays in sync with the browser’s empty value. - Adds regression tests covering non-nullable
DateTimeempty-string scenarios (and should be extended to cover async setter overloads).
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| src/Components/Components/src/EventCallbackFactoryBinderExtensions.cs | Updates binder behavior when the browser reports an empty string during change events. |
| src/Components/Components/src/BindConverter.cs | Formats nullable date/time values as empty string to keep rendered value aligned with browser state. |
| src/Components/Components/test/EventCallbackFactoryBinderExtensionsTest.cs | Adds regression tests for non-nullable DateTime empty string binder scenarios. |
NanthiniMahalingam
force-pushed
the
fix-40660
branch
from
July 8, 2026 08:20
aa24907 to
342adf0
Compare
3 tasks
sheiksyedm
temporarily deployed
to
copilot-pat-pool
August 12, 2026 08:34 — with
GitHub Actions
Inactive
sheiksyedm
temporarily deployed
to
copilot-pat-pool
August 12, 2026 08:34 — with
GitHub Actions
Inactive
sheiksyedm
temporarily deployed
to
copilot-pat-pool
August 12, 2026 08:34 — with
GitHub Actions
Inactive
sheiksyedm
temporarily deployed
to
copilot-pat-pool
August 12, 2026 08:35 — with
GitHub Actions
Inactive
Contributor
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 4 out of 4 changed files in this pull request and generated no new comments.
Suppressed comments (1)
src/Components/Components/src/EventCallbackFactoryBinderExtensions.cs:1517
- The comment on
ShouldSetDefaultOnEmptyString<T>()states that an empty string maps todefault(T)forstring => null, but the string binder usesConvertToStringwhich always converts successfully and will call the setter with""(notnull). This makes the comment misleading for readers and future changes; it should describe the default-on-empty behavior for types where conversion fails (e.g., numeric / nullable types), without implyingstringbecomes null.
// Determines whether an empty string input should reset the bound value to default(T).
// For most types an empty string maps to default(T) (e.g., string => null, int => 0, int? => null).
// However, non-nullable date/time types have no meaningful "empty" representation, so resetting them
// to default (e.g., DateTime.MinValue) would be surprising. For those we leave the existing value
// unchanged instead.
kotlarmilos
reviewed
Aug 13, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Bug Description
Inconsistent behavior occurs when using @Bind and @bind-value in input date type
Description of code changes
Output
Before changes
Beforefix40660.mp4
After changes
Afterfix40660_1.mp4
Fixes #40660