question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. ItΒ collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

type='number' on masked input - Throws error on focus and text entry

See original GitHub issue

🐞 bug report

Is this a regression?

No, the issue occurs on 11.1.5 and 11.0.0

Description

Using input type='number' with a mask of mask='0' throws an error on focus and on text entry. It appears to work correctly otherwise.

I am using input type to trigger the number keyboard on mobile devices.

πŸ”¬ Minimal Reproduction

https://stackblitz.com/edit/angular-ivy-zd58bk?devtoolsheight=33&file=src/app/app.component.html

πŸ”₯ Exception or Error

Chrome:

On focus:

ERROR
Error: Failed to set the 'selectionStart' property on 'HTMLInputElement': The input element's type ('number') does not support selection.

On text entry:

ERROR
Error: Failed to execute 'setSelectionRange' on 'HTMLInputElement': The input element's type ('number') does not support selection.

Firefox

Same error for focus and text entry:

Error: An attempt was made to use an object that is not, or is no longer, usable

🌍 Your Environment

Angular Version:


Angular CLI: 11.2.5
Node: 14.15.4
OS: darwin x64

Angular: 11.2.6
... animations, common, compiler, compiler-cli, core, forms
... platform-browser, platform-browser-dynamic, router
Ivy Workspace: Yes

Package                         Version
---------------------------------------------------------
@angular-devkit/architect       0.1102.5
@angular-devkit/build-angular   0.1102.5
@angular-devkit/core            11.2.5
@angular-devkit/schematics      11.2.5
@angular/cdk                    11.2.5
@angular/cli                    11.2.5
@angular/material               11.2.5
@schematics/angular             11.2.5
@schematics/update              0.1102.5
rxjs                            6.6.6
typescript                      4.1.5

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
ColinMorris83commented, Mar 25, 2021

I only know of selection functions which is mentioned here for what type of inputs support them: https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/setSelectionRange

1reaction
ColinMorris83commented, Mar 25, 2021

Changing the type to be β€œtel” should do what you want to

Read more comments on GitHub >

github_iconTop Results From Across the Web

Implement an input with a mask - Stack Overflow
I'm using this in a phone number input field in a modal and in some cases the user will already have a phone...
Read more >
<input>: The Input (Form Input) element - HTML
A field for editing an email address. Looks like a text input, but has validation parameters and relevant keyboard in supporting browsers andΒ ......
Read more >
Input Mask Guide | imaskjs
vanilla javascript input mask. ... Getting Started. Install from npm: npm install imask ... If you apply mask to input element you have...
Read more >
Masked Field - CMS Design System
Applies date format masking to the input value entered and renders to a text field above the input. Passing true to valueOnly will...
Read more >
Input | Quasar Framework
The QInput Vue component is used to capture text input from the user. ... validation status against the 'rules' only after field loses...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found