Skip to content

Commit

Permalink
Fix primefaces#3029: InputNumber when overwriting with suffix (primef…
Browse files Browse the repository at this point in the history
  • Loading branch information
melloware authored Nov 10, 2022
1 parent aeaa22d commit 52131cf
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
6 changes: 3 additions & 3 deletions components/lib/inputnumber/InputNumber.js
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,6 @@ export const InputNumber = React.memo(
const onUpButtonTouchEnd = () => {
if (!props.disabled && !props.readOnly) {
clearTimer();
event.preventDefault();
}
};

Expand Down Expand Up @@ -267,7 +266,6 @@ export const InputNumber = React.memo(
const onDownButtonTouchEnd = () => {
if (!props.disabled && !props.readOnly) {
clearTimer();
event.preventDefault();
}
};

Expand Down Expand Up @@ -631,7 +629,9 @@ export const InputNumber = React.memo(
} else if (end - start === value.length) {
return formatValue(text);
} else if (start === 0) {
return text + value.slice(end);
const suffix = ObjectUtils.isLetter(value[end]) ? end - 1 : end;

return text + value.slice(suffix);
} else if (end === value.length) {
return value.slice(0, start) + text;
} else {
Expand Down
4 changes: 4 additions & 0 deletions components/lib/utils/ObjectUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,10 @@ export default class ObjectUtils {
return !!(obj && obj.constructor && obj.call && obj.apply);
}

static isLetter(char) {
return char && (char.toUpperCase() != char.toLowerCase() || char.codePointAt(0) > 127);
}

static findDiffKeys(obj1, obj2) {
if (!obj1 || !obj2) {
return {};
Expand Down

0 comments on commit 52131cf

Please sign in to comment.