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 dynamic step size #19779

Open
lukasberbuer opened this issue May 8, 2024 · 1 comment
Open

[Feature Request] VNumberInput dynamic step size #19779

lukasberbuer opened this issue May 8, 2024 · 1 comment
Assignees
Labels
C: VNumberInput T: enhancement Functionality that enhances existing features

Comments

@lukasberbuer
Copy link

Problem to solve

The step prop currently only takes a number. This works well for linear scaled numbers.
I would like to use a dynamic step size (for a logarithmic scaled value):

  • increment: multiply value by 2
  • decrement: divide value by 2

Proposed solution

The prop could take a callable which returns the computed step size, e.g.:

enum StepDirection {
  Up = 1,
  Down = -1,
}
type StepFunc = (value: number, direction: StepDirection) => number;

const logStep = (value: number, direction: StepDirection) => {
  switch (direction) {
  case StepDirection.Up:
    return value;
  case StepDirection.Down:
    return -0.5 * value;
  }
};
@yuwu9145 yuwu9145 self-assigned this May 18, 2024
@yuwu9145 yuwu9145 added T: enhancement Functionality that enhances existing features C: VNumberInput and removed S: triage labels May 18, 2024
@J-Sek
Copy link
Contributor

J-Sek commented May 25, 2024

Title is a bit misleading. You do not ask for dynamic step, but for straight override of the up/down behavior.

In the current state it is not possible to achieve with VNumberInput. While we can override slots, VNumberField implementation contains preventDefault() after detecting ArrowUp and ArrowDown thus preventing parent component from detecting such interactions. I was able to implement this with VTextField [Demo].

I wish I could understand this use case a bit more. In what scenario user would expect this kind of behavior instead of adding or removing defined step value? I am curious because I felt a bit confused when interacting with the example implementation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C: VNumberInput T: enhancement Functionality that enhances existing features
Projects
None yet
Development

No branches or pull requests

3 participants