Skip to content

Conversation

@SkyZeroZx
Copy link
Contributor

@SkyZeroZx SkyZeroZx commented Feb 4, 2026

Currently, type="text" inputs are treated strictly as string values. When used with inputmode="numeric" and bound to a numeric signal field, this results in a next error :

 TS2322 error number is not assignable to string

Allows inputs configured with inputmode="numeric" to properly synchronize with signal-based form fields by accepting and normalizing both string and number values. This aligns with accessibility practices ( due to assistive technology issues e.g., problematic spinner controls and screen reader behavior) while still preserving the numeric keyboard on mobile

@Component({
  template: `
      <input
        type="text"
        inputmode="numeric"
        [formField]="f.documentNumber"    
      />
  `,
})
class InputModeExample {
  readonly data = signal({
    documentNumber: 4,
  });

  readonly f = form(this.data);
}

Other information

This addresses part of #66903 by enabling proper support for inputmode="numeric" with numeric form fields.

However, on iOS, pattern="[0-9]*" is often required to consistently trigger the numeric keypad. Since pattern is currently disallowed with [formField], that aspect remains unresolved and would need to be considered separately. ( Although we can currently use modifying the DOM directly as a workaround to add it at runtime )

@angular-robot angular-robot bot added detected: feature PR contains a feature commit area: forms labels Feb 4, 2026
@ngbot ngbot bot added this to the Backlog milestone Feb 4, 2026
Allows number inputs with `inputmode="numeric"` to be properly synchronized
with signal-based form fields, handling both string and number values

Fixes angular#66903
@SkyZeroZx SkyZeroZx force-pushed the sf/add-input-mode-types branch from 84dded9 to a01be7c Compare February 5, 2026 05:06
for (const attr of node.attributes) {
if (attr.name.toLowerCase() === 'inputmode') {
const value = attr.value.toLowerCase();
return value === 'numeric';
Copy link
Contributor Author

Choose a reason for hiding this comment

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

For this PR, should we consider adding support for other numeric input modes (e.g. decimal, tel), or would it be better to handle that in a follow-up PR?

https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/inputMode

@SkyZeroZx SkyZeroZx marked this pull request as ready for review February 5, 2026 05:09
@pullapprove pullapprove bot requested a review from AndrewKushnir February 5, 2026 05:09
@AndrewKushnir AndrewKushnir requested review from kirjs and removed request for AndrewKushnir February 5, 2026 05:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

2 participants