properly update number fields with non-numeric values

fixes a bug where the field was not properly filled in when the tag contained a non-numeric value (e.g. `direction=S`), which could eventually cause the tag be deleted inadvertently after focussing/blurring the field.

closes #11076

this regressed in 2b64d70352
This commit is contained in:
Martin Raifer
2025-06-03 20:44:48 +02:00
parent 5cb19f2cb1
commit 42ea10d30a
2 changed files with 14 additions and 6 deletions
+12 -6
View File
@@ -501,12 +501,18 @@ export function uiFieldText(field, context) {
// by pressing the +/- buttons or using the raw tag editor), we
// can and should update the content of the input element.
shouldUpdate = (inputValue, setValue) => {
const inputNums = inputValue.split(';').map(setVal =>
likelyRawNumberFormat.test(setVal)
? parseFloat(setVal)
: parseLocaleFloat(setVal)
);
const setNums = setValue.split(';').map(parseLocaleFloat);
const inputNums = inputValue.split(';').map(val => {
const parsedNum = likelyRawNumberFormat.test(val)
? parseFloat(val)
: parseLocaleFloat(val);
if (!isFinite(parsedNum)) return val; // keep unparsable values as-is
return parsedNum;
});
const setNums = setValue.split(';').map(val => {
const parsedNum = parseLocaleFloat(val);
if (!isFinite(parsedNum)) return val; // keep unparsable values as-is
return parsedNum;
});
return !isEqual(inputNums, setNums);
};
}