Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature Request] VNumberInput allow Parsing and Fallback for min and max Values in VNumberInput #20788

Closed
3dyuval opened this issue Dec 18, 2024 · 1 comment · May be fixed by #20790
Closed

Comments

@3dyuval
Copy link

3dyuval commented Dec 18, 2024

Problem to solve

The current VNumberInput does not automatically handle non-numeric min and max values, nor does it provide fallback mechanisms for values exceeding JavaScript's safe integer ranges, resulting in possible input errors or unexpected behavior.

Proposed solution

Implement a parsing mechanism to interpret min and max, and automatically resort to Number.MIN_SAFE_INTEGER or Number.MAX_SAFE_INTEGER when inputs are invalid or exceed safe numeric limits, ensuring robust and predictable component behavior.

Playground

3dyuval pushed a commit to 3dyuval/vuetify that referenced this issue Dec 18, 2024
Enhanced the `VNumberInput` component to include parsing logic for `min` and `max` properties. Implemented automatic fallback to `Number.MIN_SAFE_INTEGER` and `Number.MAX_SAFE_INTEGER` when values are non-numeric or exceed safe integer ranges. This ensures consistent and reliable behavior under edge cases.

resolves vuetifyjs#20788
@J-Sek
Copy link
Contributor

J-Sek commented Dec 18, 2024

min and max are already set to *_SAFE_INTEGER as default:

  min: {
    type: Number,
    default: Number.MIN_SAFE_INTEGER,
  },
  max: {
    type: Number,
    default: Number.MAX_SAFE_INTEGER,
  },

By setting them to Infinity and -Infinity you would override these defaults and accept numbers outside of range that framework defined as reasonable boundaries for typical use. But that's not the problem here anyways.

The problem in the Playground

image

So adding "1" results in the same value. Seems like it is what "SAFE" means - once you exceeded safe range, math does not apply.

Workaround :step='2'

<v-number-input
  class="max-out-of-range1"
  :max="Number.MAX_SAFE_INTEGER + 2"
  :step="2"
  v-model="value2"
/>

<v-number-input
  class="max-out-of-range2"
  :max="Infinity"
  :step="2"
  v-model="value3"
/>

@J-Sek J-Sek closed this as not planned Won't fix, can't repro, duplicate, stale Dec 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants