fix(frontend): keep integer property fields editable by replacing the crashing Formly number parser#6058
Open
yangzhang75 wants to merge 1 commit into
Open
Conversation
… crashing Formly number parser
@ngx-formly/core's json-schema integer/number parser reads
document.querySelector('#'+field.id).validity.badInput, assuming the id is on the
native <input>. ng-zorro's nz-input-number puts the id on its host element, which has
no .validity, so the parser throws 'Cannot read properties of undefined (reading
badInput)' whenever the parsed value is null (an intermediate state while typing).
Typed edits then never commit and the field is stuck (only the +/- steppers work).
Replace the numeric fields' parser in jsonSchemaMapIntercept with a null-safe parser
that does no DOM access.
Contributor
Automated Reviewer SuggestionsBased on the
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #6058 +/- ##
============================================
+ Coverage 56.37% 56.40% +0.02%
Complexity 2992 2992
============================================
Files 1129 1130 +1
Lines 43802 43816 +14
Branches 4743 4749 +6
============================================
+ Hits 24695 24714 +19
+ Misses 17658 17650 -8
- Partials 1449 1452 +3
*This pull request uses carry forward flags. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Contributor
Author
|
/request-review @mengw15 |
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.
What changes were proposed in this PR?
Fixes typed edits being ignored on integer/number operator property fields (reproduced
on the Limit operator): the field gets stuck and only the +/- steppers work.
Root cause:
@ngx-formly/core's json-schema integer/number parser readsdocument.querySelector('#' + field.id).validity.badInput, assuming the id is on thenative
<input>. ng-zorro'snz-input-numberputs the id on its host element (whichhas no
.validity), so the parser throwsCannot read properties of undefined (reading 'badInput')whenever the parsed value is null (an intermediate state whiletyping). The typed value then never commits.
This replaces that parser, for numeric fields only, with a null-safe parser that does
no DOM access (
applySafeNumericParserinjsonSchemaMapIntercept). The stepper pathwas unaffected and keeps working.
Any related issues, documentation, discussions?
Closes #6054
How was this PR tested?
parseNumericInput(numeric/decimal/negative/whitespace/empty/non-numeric/DOM-safety) and
applySafeNumericParser(replaces the crash-prone parser,null-safe on the clear-field case, leaves non-numeric fields untouched) — 12 tests.
OperatorPropertyEditFrameComponentspec still passes.and the console
badInputTypeError is gone.Was this PR authored or co-authored using generative AI tooling?
Generated-by: Claude Code (Claude Opus 4.8)