Skip to content

Commit 08f8e35

Browse files
authored
fix(ui5-step-input): prevent false validation error with valuePrecision (#12778)
Previously when users entered whole numbers or numbers with fewer decimals than required by valuePrecision, the component incorrectly showed "Invalid Entry" error even though the value was automatically formatted correctly. Now integer values will always be formatted with the correct precision via toFixed(), making them valid regardless of how they were entered (e.g., "5" or "5.0" with valuePrecision=2 both become "5.00").
1 parent 43e545a commit 08f8e35

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

packages/main/src/StepInput.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -513,6 +513,13 @@ class StepInput extends UI5Element implements IFormInputElement {
513513
}
514514

515515
get _isValueWithCorrectPrecision() {
516+
// check if the value will be displayed with correct precision
517+
// _displayValue has special formatting logic
518+
if ((this.value === 0) || (Number.isInteger(this.value))) {
519+
// integers and zero will be formatted with toFixed, so they're always valid
520+
return true;
521+
}
522+
516523
// gets either "." or "," as delimiter which is based on locale, and splits the number by it
517524
const delimiter = this.input?.value?.includes(".") ? "." : ",";
518525
const numberParts = this.input?.value?.split(delimiter);

0 commit comments

Comments
 (0)