Repository navigation
Conversation
…eset `writeValue` skipped re-formatting the input when the incoming value was the same as the current one. This was added in angular#32447 and angular#32485 to work around signal forms writing the same value back into the CVA while the user was typing (angular#32442, angular#32475). As a side effect, calling `reset()` or `setValue(null)` after the user typed an unparseable date left the invalid text in the input without a parse error. Signal forms `reset()` was affected as well. Angular 22.0.0 deduplicates `writeValue` calls in the CVA interop (angular/angular@2e9aeea0f), so the workaround is no longer necessary. These changes remove it so that `writeValue` always re-formats the input. Fixes angular#33978.
This branch has not been deployed
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.
Fixes #33978.
Problem
writeValueskipped re-formatting the input when the incoming value was the same as the current one. This was added in #32447 and #32485 to work around signal forms writing the same value back into the CVA while the user was typing (#32442, #32475).As a side effect, an unparseable value could no longer be cleared programmatically. After the user types something like
foo, the model value isnull, soreset()/setValue(null)callswriteValue(null)with the value that's already there and gets skipped. The invalid text stays in the input, and because_lastValueValidis reset, nomatDatepickerParseerror is shown either. Signal formsreset()goes through the same path and is affected as well.Fix
Angular 22.0.0 deduplicates
writeValuecalls in the CVA interop (angular/angular@2e9aeea0f), and@angular/material22 requires@angular/core ^22.0.0, so the workaround is no longer needed. This PR removes it sowriteValuealways re-formats the input, and drops the now-unusedreformatparameter from_assignValueProgrammatically.Tests
reset()clears invalid text.[formField]integration:reset()clears invalid textI also checked it manually in an Angular / Material 22.2.3 app, before and after patching:
foo, thenreset()foostaysbar, thensetValue(null)barstaysfoo, thenreset()foostaysfoo1→1/→ … →1/1/2026debounce: same typing sequences