Backport 41868 to release/6.0 #41870
Merged
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.
Fix time/datetime-local binding with seconds when there's no step attribute
Restores the ability to do
<input type=time @bind="someDateTimeVariable">without getting a weird browser warning ifsomeDateTimeVariablehas a non-zero "seconds" component. This used to work in 5.0 but regressed in 6.0.Description
In 5.0, there was explicit JS-side logic to handle the case where an
<input type=time>had nostepattribute (which browsers interpret as "use whole number of minutes - no seconds"). We automatically stripped off any "seconds" part of the formatted string to make it valid as far as the<input type=time>is concerned. This behavior was unintentionally lost in 6.0.Fixes #41731
Customer Impact
Without this change:
DateTimeorTimeOnlyvalues have a zero "seconds" component when used with<input type=time>or<input type=datetime-local>... would find that:
<input type=time>or<input type=datetime-local>would have a nonzero "seconds" component only if they have not been edited by the user, which is pretty oddRegression?
Worked in 5.0
Risk
It is plausible that a 6.0 developer has taken a dependency on this weird behavior. For example, they might be using the
<input type=time>as a readonly value, and be relying on the ability to round-trip a value that includes a nonzero "seconds" part. However:The 5.0 behavior is objectively better, so I have no doubt we should fix this in 7.0. Whether or not we should also patch 6.0 and accept the risk that some developer actually wants the bug is a more ambiguous question.
Verification
Packaging changes reviewed?