Conversation
…ared Clearing the datepicker or daterangepicker input passed undefined to the form's onChange callback. Signal forms treats an undefined model property as a removed field, so [formField] crashed with "this.field(...) is not a function" and the field could never be updated again. Emit null, matching FormControl, the timepicker and Material's datepicker. Closes valor-software#6832
mnkprs
force-pushed
the
fix/datepicker-signal-forms-null
branch
from
September 12, 2026 17:43
5f7687b to
7cb0bb5
Compare
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.
PR Checklist
Before creating new PR, please take a look at checklist below to make sure that you've done everything that needs to be done before we can merge it.
Root cause
BsDatepickerInputDirectiveandBsDaterangepickerInputDirectivecall their registeredonChange(the value accessor callback) withundefinedwhenever the input is cleared -either by typing/deleting the text and blurring, or via the picker's own clear action, which
routes through the same
bsValueChangesubscription.Angular's new Signal Forms (
@angular/forms/signals) treats a model property that isexplicitly set to
undefinedas "this field no longer exists" and deletes the correspondingFieldNode(FieldNodeStructure.computeChildrenMap). Once that happens, any further access tothe field - including
FormField's ownstatecomputed (this.field()()) - throws:...and the field can never be updated again, exactly as reported in #6832.
Change
Emit
nullinstead ofundefinedfrom the CVAonChangecallback whenever the datepicker ordaterangepicker input is cleared (both the native
changeevent path and the picker-drivenbsValueChangepath, for both directives).nullis the conventional "empty" sentinel alreadyused by
FormControl's own default, by this library's own timepicker (onChange(null)on aninvalid/empty entry), and by Angular Material's datepicker. Internal state (
_value, the publicbsValueinput,writeValue,validate) is unchanged; only the value handed to the form isnormalized at the point it's emitted.
Angular/components applied the identical fix for the same Signal Forms failure mode in
angular/components#33708 (chip listbox
deselection).
Tests
Added
src/datepicker/testing/bs-datepicker-input.spec.tscovering both directives:bsValue(the picker's own clearpath), both now leave
control.valueasnullrather thanundefined, forbsDatepickerandbsDaterangepicker.[formField]to absDatepickerinput and clearing it no longer throwsthis.field(...) is not a function, the field's model value becomesnull, and the field staysalive so a subsequently selected date still reaches the model.
All new specs fail against the current
developmentcode (reproducing #6832, including theexact error message) and pass with this change.
Validation:
npx nx test datepicker: 57 passed, 2 skipped.npm test -- --parallel=2 --runInBand: all 24 projects passed.npx nx lint datepickerandnpm run lint -- --parallel=2: all 46 projects passed, 0 errors(pre-existing, unrelated warnings only).
npx nx build datepicker --configuration=production: passed.Behavioral note
Consumers reading the cleared value from
ngModel/FormControl/[formField]now receivenullinstead ofundefined. This only affects the "cleared" case; a date value is unaffected.Fixes #6832