Skip to content

fix(input): sync reactive model when the numeric guard reverts a character - #440

Open
gkbishnoi07 wants to merge 2 commits into
angular-zard-migrationfrom
fix/numeric-field-model-sync
Open

fix(input): sync reactive model when the numeric guard reverts a character#440
gkbishnoi07 wants to merge 2 commits into
angular-zard-migrationfrom
fix/numeric-field-model-sync

Conversation

@gkbishnoi07

Copy link
Copy Markdown

What

Duration / numeric fields accepted letters into the saved payload. The StringValidatorDirective reverted the visible character but never synced the reactive-form model, so a rejected character could persist in the value sent to the backend.

Fix

Add a guarded model re-sync in StringValidatorDirective so the reactive control matches the (cleaned) visible input.

Testing

Shared directive — verify across numeric fields (Chief Complaints / Personal History Duration, vitals, registration): typing letters is rejected on screen and not saved. (QA: Duration field is taking char as input.)

…acter

The allowText/StringValidator guard reverts a rejected character in the DOM
(event.target.value = lastVal) but never updated the reactive FormControl, so the
value accessor could keep the rejected char in the saved payload while the visible
box looked clean. Re-emit 'input' after a revert so the corrected value is written
back into the model; guarded against re-entrancy so the (now valid) re-emitted
event cannot recurse. Fixes MMU bugfest [15] for Duration and other numeric fields.
@coderabbitai

coderabbitai Bot commented Aug 16, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: f3e866db-e3d2-4ce6-9a54-34a92cd3baf8

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

this.validateEntry(val, lastVal, maxlength, event);
}

// If a guard above reverted/overrode the visible value, the reactive form

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we remove this?

@sonarqubecloud

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants