primefaces / primevue

Next Generation Vue UI Component Library
https://primevue.org
MIT License
10.44k stars 1.23k forks source link

InputNumber: Component breaks when I try to set `type="number"` for the input keyboard variant #5533

Open FabianMontoya opened 7 months ago

FabianMontoya commented 7 months ago

Describe the bug

I want to improve the accessibility of my inputs, in this case, the InputNumber that, in my case, the user set his weight info, for that, is normally that if the user is in mobile, the keyboard variant (more info HTML5 Input Type Keyboards) should be the number variant, to be easy for the user input the values.

The problem is that the InputNumber component doesn't take in count the type attribute, and if i set it using the :pt option, the input breaks.

:pt="{
  input: {
    root: {
      type: 'number',
    },
  },
}"

I'm getting the error:

Uncaught DOMException: Failed to execute 'setSelectionRange' on 'HTMLInputElement': The input element's type ('number') does not support selection.
Complete error track ``` Uncaught DOMException: Failed to execute 'setSelectionRange' on 'HTMLInputElement': The input element's type ('number') does not support selection. at Proxy.updateInput (http://localhost:5173/node_modules/.vite/deps/chunk-52XFH2BU.js?v=072a68cf:1024:30) at Proxy.updateValue (http://localhost:5173/node_modules/.vite/deps/chunk-52XFH2BU.js?v=072a68cf:979:14) at Proxy.insert (http://localhost:5173/node_modules/.vite/deps/chunk-52XFH2BU.js?v=072a68cf:881:16) at Proxy.onInputKeyDown (http://localhost:5173/node_modules/.vite/deps/chunk-52XFH2BU.js?v=072a68cf:772:18) at callWithErrorHandling (http://localhost:5173/node_modules/.vite/deps/chunk-TAAYGLYS.js?v=072a68cf:1868:19) at callWithAsyncErrorHandling (http://localhost:5173/node_modules/.vite/deps/chunk-TAAYGLYS.js?v=072a68cf:1875:17) at HTMLInputElement.invoker (http://localhost:5173/node_modules/.vite/deps/chunk-TAAYGLYS.js?v=072a68cf:10561:5) ```

__

Reproducer

https://stackblitz.com/edit/primevue-create-vue-issue-template-ew6cb8?file=src%2FApp.vue

PrimeVue version

3.51.0

Vue version

3.x

Language

TypeScript

Build / Runtime

Vite

Browser(s)

Chrome 122.0.6261.129 (Official Build) (arm64)

Steps to reproduce the behavior

  1. Implement the InputNumber component.
  2. Set the input type using :pt prop
    :pt="{
    input: {
    root: {
      type: 'number',
    },
    },
    }"
  3. Change the input value writing or using the buttons.

Expected behavior

If the user is using a mobile/tablet device, the varian keyboard that the user see is the numeric variant and the user can change the input value

For more info, you can refer the mdn Web Docs

EJ:

image

image

tknaller commented 6 months ago

same issue in primereact