Repository navigation
Conversation
|
I've run the unit tests added in PR #69637 against this branch to check if they all pass. It seems the current fix in this PR does not fully handle all the edge cases covered by those tests. Specifically, the following 3 tests are failing:
For context, PR #69637 resolved these issues by introducing a custom |
|
Added unit tests and switched to a strict decimal parser (Number and parseFloat must agree) shared between isIntermediate and the text-input numeric read path. This fixes the -0 normalization and stops 0b0101/0x22 from being accepted as numbers. Pushed in e3553b8. |
|
Both threads addressed: Test coverage (@JeanMeche): added DOCUMENT injection (@SkyZeroZx): good catch, thanks. Switched to |
|
what is holding this up? Can we expect this to be merged any time soon? Thanks :) |
|
The test jobs on this PR are green. The merge status check lists what is left: pullapprove reports 2 pending code reviews, the required The review feedback is addressed. Unit tests landed in |
JeanMeche
left a comment
There was a problem hiding this comment.
AGENT: Great work on addressing the previous feedback! The use of the injected DOCUMENT and the added tests look good.
However, I noticed a critical edge case that this fix doesn't fully solve for <input type="number"> on Chromium-based browsers (Chrome/Edge). I've left a few inline suggestions below to address this and to consider scientific notation for text inputs.
|
Thanks for the detailed review. Addressed in 0679492, pushed to this branch.
Ran the zoneless_web_test_suite target for packages/forms/signals/test/web (Chromium and Firefox), prettier --check, and tslint on the touched files; all pass. Not changed: no new accessor on InputValidityMonitor (isBadInput already existed), and no changes to parseDecimalNumber or isIntermediate's whitelist for point 3, for the reason above. |
|
Follow-up in b4094a1: a model write deferred while the number input has badInput is now applied on blur. A later user edit or reset cancels that pending write, and blur reads the current field binding. In the September 18 local verification, the regression failed before the fix in both browsers. After the fix, the full signals web suite passed: Chromium 360; Firefox 356 with 4 skips. Formatting and project-aware lint passed. Native Chrome typing also verified blur synchronization, newer valid/invalid edits, reset, and rebinding. |
d1bcbbe to
b035e76
Compare
|
The adev job failed the NodeRuntimeSandbox out-of-memory test on all three attempts. It expected one call to The sandbox, spec, alert manager and BUILD files are identical at CI base |
9b3f80a to
b263638
Compare
JeanMeche
left a comment
There was a problem hiding this comment.
AGENT: Thanks for the updates @shoemoney! Extracting parseDecimalNumber and tracking lastEditedValue / hasPendingValueWrite cleaned up a lot of the previous issues. Taking a closer look at isIntermediate and hasPendingValueWrite, there are still a few edge cases and simplifications worth addressing.
|
Addressed in 10bcf30. Write-back /
Tests: those two strings expect an immediate update;
|
|
Can you please squash everything and drop the co-author. We cannot proceed with a PR that fails the CLA check. Thank yuo. |
10bcf30 to
91a9b57
Compare
91a9b57 to
13de728
Compare
|
Thanks for the review and for spelling out the CLA blocker. I rebased onto current main and pushed 13de728 as a single commit authored and committed solely by me, with no co-author trailer. The inline fixes and regression tests are included, and I resolved the addressed threads. The Signal Forms browser target passes in Chromium and Firefox; formatting, targeted lint, and commit-message validation also pass. This is ready for another review. The workflow approvals, internal presubmit, and target label still need maintainer action. |
|
A case this doesn't cover yet, in Chrome (158.0.8127.37) on 22.1.5 (the write-back is unchanged in 22.3.0):
With this PR, Since the input listener already records (This comment was prepared with Claude, but we are running into this issue on production.) |
|
Thanks for the precise Chrome reproduction, @karptonite. Fixed in 32e79a7: a focused number input avoids echoing its own edit, and real model writes/reset/blur clear that edit marker so later external updates still apply. I reproduced the |
|
Thanks, @shoemoney, I really appreciate it! I hope this is merged soon--I don't know how the process for PRs generally works on Angular, but this seems like a really worthwhile bug fix! |
|
Thanks, @karptonite! Your reproduction helped catch the remaining caret issue. I hope it lands soon too. The timing is up to the Angular maintainers; I’ll keep an eye on the PR and address any further feedback. |
JeanMeche
left a comment
There was a problem hiding this comment.
AGENT: Stepping back and looking at the current implementation, there is a broader design question worth considering alongside a few concrete edge cases noted inline.
Should external model updates be deferred at all?
This PR has accumulated three mutable state flags (hasPendingValueWrite, lastEditedValue, hasUserEdit), isIntermediate(), isBadInput, and a blur-flush path because it mixes two distinct concerns:
- Avoiding echoing the user's own edit back to the same element (the root cause of #69635, and why
32e79a7still had to addinput.type === 'number' && isUserEditfor Chrome displaying14.while reporting"14"withoutbadInput). - Deferring external model writes until blur while a focused input holds an intermediate spelling or
badInput.
Deferring external updates creates inconsistent behavior: a programmatic model write (e.g. a keyboard shortcut, "Reset"/"Max" action that doesn't steal focus, or linked field update) applies immediately if the focused input currently shows 14, but is silently deferred until blur if it shows 14.0, -0, or -. Every other Angular form control applies external model writes immediately even while focused.
If we instead only skip echoing the user's own edit back to the DOM (and clear edit tracking once consumed / on blur / on reset), 14., 1.0, -0, -, and 1e are all preserved during typing without needing isIntermediate(), hasPendingValueWrite, deferred blur flushes, or rejecting scientific notation in parseDecimalNumber, while external updates stay consistent and immediate.
Other notes
- Please see the inline comments on
isIntermediate(leaking into non-numeric controls andstring | null),watchValidity(droppinghasPendingValueWriteon non-user validity changes),parseDecimalNumber(acceptingInfinity/-Infinity/+Infinityand breaking1e5on text inputs), andinject(DOCUMENT)overhead. - Before merging, please also squash the two commits into one and make sure the full
//packages/forms/signals/test/web:testsuite passes on the latest head.
32e79a7 to
b393fb4
Compare
|
Thanks @JeanMeche for the concrete external-write and validity-notification examples. I replaced the deferral logic with a marker for a real input event's own echo, consumed on every update. External model writes now update immediately; validity notifications use their original callback. The document injection and parser helper are gone, so scientific notation and the existing Infinity behavior are preserved. I squashed the PR to one commit, I added 19 focused TestBed cases, including a setter assertion distinguishing validity notifications from user input. Those cases and the full |
Skip the native value write for the control value produced by a user input event, then consume the marker on every update. Keep external writes immediate and preserve existing parsing semantics. Cover native edits, resets, validity notifications and supported nullable numeric and string clearing models.
b393fb4 to
59f1b50
Compare
PR Checklist
Please check if your PR fulfills the following requirements:
PR Type
What kind of change does this PR introduce?
What is the current behavior?
A native signal FormField writes a parsed user value back to the DOM during the next update. That can discard the spelling being edited or move the caret. For example, Chromium can display
14.while exposingvalue="14"andbadInput=false; writing14back loses the dot and disrupts the next digit.Fixes #69635.
What is the new behavior?
A real input event records its resulting control value. The next directive update skips echoing that value to the DOM and consumes the marker, including when the binding value has not changed. External model changes continue to update every native control immediately. Reset always writes the model value, blur clears the marker, and changes to a radio's value binding still force synchronization.
Validity notifications keep their separate parsing callback. The change adds no document injection, focus checks, deferred writes or intermediate-number parser. Existing
Number()parsing, including scientific notation and Infinity for numeric text controls, is preserved.Does this PR introduce a breaking change?
Other information
The PR is one commit on
ef7ae1fc41d885d1c6744ad5ddf472880b930cad. Existing web tests are preserved. The newnative_control_edit.spec.tsadds 19 TestBed cases covering the own-edit echo, immediate external updates, numeric spellings, the existing numeric parsing contract, nullable controls, radio bindings, validity notifications and reset. These 19 TestBed cases have not been run.Validation for
b393fb4adb5fcf5766d608acc6e39bc1a009f460:pnpm ng-dev format filesandpnpm ng-dev format changed --check refs/remotes/upstream/maincommands pass with the pinned formatter from current main. TypeScript syntax parsing andgit diff --checkpass.14.typing in light and shadow DOM, immediate external writes, nullable controls, scientific notation/Infinity, radio changes, validity notifications and reset. Four deliberately broken variants fail the corresponding checks.pnpm bazel test //packages/forms/signals/test/web:test, remains unrun. The remote validation launch was cancelled before commands executed, so the complete TestBed/Bazel validation is still outstanding.