Skip to content

Signal Forms allow diferent numeric input methods #66903

@air2

Description

@air2

Which @angular/* package(s) are relevant/related to the feature request?

No response

Description

Currently when your formField data is a number the input must be of type number.
Consider this form:

readonly data = signal({ age: 4})
readonly f = form(this.data)

And this form

<input type="number" [formField]="f.age">
<input type="number" [formField]="f.age" pattern="[0-9]*">
<input type="text" [formField]="f.age" inputmode="number" pattern="[0-9]*"  >

This gives several problems.

  1. For one patterns are not allowed. This is according the W3C spec, but some mobile systems (IOS) allow to show the numeric keyboard when you put the pattern="[0-9]*" on a number input.
  2. For real good accessibility/mobile support <input type="text" inputmode="number"> is preferred, but because the
    type is text, it is not allowed. The problems that are solved by this kind of input are explained very well on this site: https://technology.blog.gov.uk/2020/02/24/why-the-gov-uk-design-system-team-changed-the-input-type-for-numbers/

Proposed solution

Allow <input type="text inputmode="number"> for form fields of the numerical type and support the pattern="[0-9]*"

Alternatives considered

Creating a custom control, and I think this is currently the only workable solution.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status

    No status

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions