From bcf269d92f0a0bfbc8410692560e92ee322b7f74 Mon Sep 17 00:00:00 2001 From: gerjanvangeest Date: Thu, 15 May 2025 08:05:51 +0200 Subject: [PATCH] chore(input-stepper): small edit after previous input-stepper fix (#2523) --- .changeset/silver-eyes-count.md | 4 ++-- .../components/input-stepper/src/LionInputStepper.js | 11 ++++------- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/.changeset/silver-eyes-count.md b/.changeset/silver-eyes-count.md index 08ba9fa51..b09e2e5a4 100644 --- a/.changeset/silver-eyes-count.md +++ b/.changeset/silver-eyes-count.md @@ -1,5 +1,5 @@ --- -"@lion/ui": patch +'@lion/ui': patch --- -feat(input-stepper): add alignToStep property to align value with step value +[input-stepper] align value with step value diff --git a/packages/ui/components/input-stepper/src/LionInputStepper.js b/packages/ui/components/input-stepper/src/LionInputStepper.js index fb866455b..ebc0fe6ad 100644 --- a/packages/ui/components/input-stepper/src/LionInputStepper.js +++ b/packages/ui/components/input-stepper/src/LionInputStepper.js @@ -265,17 +265,14 @@ export class LionInputStepper extends LocalizeMixin(LionInput) { * @private */ __increment() { - const { step, max } = this.values; - let { min } = this.values; - if (min === Infinity) { - min = 0; - } + const { step, min, max } = this.values; + const stepMin = min !== Infinity ? min : 0; let newValue = this.currentValue + step; - if ((this.currentValue + min) % step !== 0) { + if ((this.currentValue + stepMin) % step !== 0) { // If the value is not aligned to step, align it to the nearest step - newValue = Math.floor(this.currentValue / step) * step + step + (min % step); + newValue = Math.floor(this.currentValue / step) * step + step + (stepMin % step); } if (newValue <= max || max === Infinity) {