Signal Forms: debounce('blur') loses the typed value when the focused input is removed
Which @angular/* package(s) are the source of the bug?
forms
Is this a regression?
No
Description
With debounce(path, 'blur'), the typed value is only written to the model when the control is blurred. If the focused input is removed from the DOM before it is blurred (an @if, a wizard step, a tab switch, a route change), the pending value is never written. The user's input is silently lost.
Steps:
- Type into an input that uses
debounce(path, 'blur'). - Press Enter, which runs
(keydown.enter)and removes the input through@if. Don't click or Tab away first. - The model still has its old value.
Browsers:
- Safari 26.5: reproduces. Safari follows the HTML "focus fixup" rule and fires no
blurwhen a focused element is removed, so nothing flushes the pending value. - Chrome: does not reproduce, because Chrome fires
blurright before it removes the focused element, while Angular's listener is still attached. - Firefox: not tested.
Duration debounces (debounce(path, 300)) keep the value in every browser, because the timer still fires after the input is destroyed. Only 'blur' mode depends on the blur event.
As far as I can tell, 'blur' mode only ends when the control's blur listener calls markAsTouched(), which flushes the pending sync. Nothing flushes it when the control is destroyed.
The reproduction has a "Recorder" list that shows the events in order. In Chrome there is a blur and a model update before the input is removed. In Safari there is neither.
Please provide a link to a minimal reproduction of the bug
https://github.com/arturovt/signal-forms-blur-debounce-repro
Please provide the exception or error you saw
No error. The value typed into the input is silently not written to the model.Please provide the environment you discovered this bug in (run ng version)
Angular CLI : 22.2.0
Angular : 22.2.0
Node.js : 24.15.0
Package Manager : pnpm 11.10.0
Operating System : darwin x64
@angular/build 22.2.0
@angular/cli 22.2.0
@angular/common 22.2.0
@angular/compiler 22.2.0
@angular/compiler-cli 22.2.0
@angular/core 22.2.0
@angular/forms 22.2.0
@angular/platform-browser 22.2.0
rxjs 7.8.2
typescript 6.0.3Anything else?
No response
Source: angular/angular