Skip to content

Commit

Permalink
refactor: manage format on blur/focus on the Increment input (#814)
Browse files Browse the repository at this point in the history
* RM#87393
  • Loading branch information
vhu-axelor authored and lme-axelor committed Dec 5, 2024
1 parent 3454d31 commit f12a2d5
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
5 changes: 5 additions & 0 deletions changelogs/unreleased/87393.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"title": "Increment: modify format management on blur/focus",
"type": "refactor",
"packages": "ui"
}
8 changes: 7 additions & 1 deletion packages/ui/src/components/molecules/Increment/Increment.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,9 @@ const Increment = ({
};

const handleEndInput = () => {
const unformattedValue = defaultFormatting ? unformat(valueQty) : valueQty;
const unformattedValue = defaultFormatting
? valueQty.replaceAll(',', '.')
: valueQty;

if (unformattedValue === '' || unformattedValue == null) {
handleResult(0);
Expand All @@ -160,6 +162,10 @@ const Increment = ({
};

const handleFocus = () => {
if (defaultFormatting) {
setValueQty(current => unformat(current).replace('.', decimalSpacer));
}

if (inputRef.current) {
inputRef.current.setSelection(0, valueQty.length);
}
Expand Down

0 comments on commit f12a2d5

Please sign in to comment.