Use different input type

Created on 7 August 2023, over 1 year ago
Updated 24 May 2024, 7 months ago

Problem/Motivation

Currently the phone input uses the textfield type.

Should it use tel or number instead?

https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/tel
https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/number

That would enable the browser to apply sensible default behaviours.

Feature request
Status

Needs review

Version

2.0

Component

Code

Created by

🇬🇧United Kingdom malcomio

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @malcomio
  • 🇮🇳India Shreya_98

    review this patch file of input uses for phone number .

  • 🇧🇪Belgium tim-diels Belgium 🇧🇪

    Hi @shreya_98, thanks for your patch. Please read https://www.drupal.org/docs/develop/git/using-git-to-contribute-to-drupa... for further help in issue queues for creating patches. The naming of the patch is not as expected. And does it passes all tests?

    @malcomio I'm just a co-maintainer that took over the project. So the initial architecture was there already. We could however see if we can change the input type if thats needed and does not break anything. Do you know the pros and cons of the change?

  • Open in Jenkins → Open on Drupal.org →
    Core: 10.0.7 + Environment: PHP 8.1 & MySQL 8
    last update over 1 year ago
    CI aborted
  • Open in Jenkins → Open on Drupal.org →
    Core: 9.5.x + Environment: PHP 8.1 & MySQL 8
    last update over 1 year ago
    CI aborted
  • 🇮🇳India shiv_yadav

    elements of type tel are used to let the user enter and edit a telephone number.

  • 🇮🇳India Shreya_98

    @tiem-diels i had changed the name of patch file according to the naming convention .

  • 🇧🇪Belgium tim-diels Belgium 🇧🇪

    @shiv_yadav posting the same patch will not get you any credits and is not productive for a maintainer to review. There was no need for a rewrite of the patch. Therefor I'm hiding your patch.

    @shreya_98 Thanks for the adjustment.

    Lets first discuss if this is even needed before we add this.

  • 🇮🇳India Shreya_98

    @tim-diels as per my knowledge if we add field type as a "tel" then it will fine for single country if we want globally then we have to add validation and then field type will be "textfield".

  • 🇬🇧United Kingdom malcomio

    One benefit of using the tel input type is that mobile browsers present a more appropriate keyboard when the input is focused.

    I'm not entirely sure whether it is a good idea, because of the way that the element has two parts.

    I can't think of any disadvantages of changing the type, but the comment above from @Shreya_th suggests that it may have an impact on the validation - not sure what that would be though.

  • 🇧🇪Belgium tim-diels Belgium 🇧🇪

    @Shreya_th please stop spamming this issue. It won't help in getting this committed. This won't be fixed easily. We need to discuss this first.

    As malcomio points out, maybe we don't need to do this.

    Can someone properly test the whole flow by adding fields and using the tel instead of textfield?

  • 🇮🇳India Shreya_98

    @tim-diels i'm not spamming this issues actually i wanted to do changes in my comment but unfortunately it saved by mistake without any comment.

  • Status changed to Needs review 7 months ago
  • Open on Drupal.org →
    Core: 10.2.1 + Environment: PHP 8.1 & MySQL 8
    last update 7 months ago
    Waiting for branch to pass
  • 🇺🇸United States chrisolof

    I like this idea. I don't think number is the right type (we'd lose the excellent input format flexibility we have today), but I see no downsides to switching to tel. It sounds like it would have client-side UX benefits and supports all phone number formats (assuming we don't specify a pattern).

    I think this also opens up some neat future possibilities. The patch looks fine but needs testing.

    Also, related, over in 🐛 Undefined array key "extension" in /src/Element/PhoneNumber.php on line 237 Needs review I'm proposing we switch the extension sub-field type to number.

Production build 0.71.5 2024