mirror of
https://github.com/FoggedLens/iD.git
synced 2026-05-25 09:34:04 +02:00
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:
@@ -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);
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user