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:
@@ -50,6 +50,7 @@ _Breaking developer changes, which may affect downstream projects or sites that
|
||||
* Refresh numeric input fields after leaving focus with the value that is stored in the tag ([#11027])
|
||||
* Fix oneway field falsely showing "Assumed to be Yes" if cycled through all options back to the default state
|
||||
* Fix false positives in "unreachable oneway" validation when `oneway=-1` tag is present ([#11068])
|
||||
* Fix a bug which can cause non-numeric values in tags of numeric input fields to not be displayed and potentially inadvertently cleared ([#11076])
|
||||
#### :earth_asia: Localization
|
||||
#### :hourglass: Performance
|
||||
#### :mortar_board: Walkthrough / Help
|
||||
@@ -62,6 +63,7 @@ _Breaking developer changes, which may affect downstream projects or sites that
|
||||
[#11027]: https://github.com/openstreetmap/iD/pull/11027
|
||||
[#11054]: https://github.com/openstreetmap/iD/issues/1104
|
||||
[#11068]: https://github.com/openstreetmap/iD/issues/11068
|
||||
[#11076]: https://github.com/openstreetmap/iD/issues/11076
|
||||
[@keiffer213]: https://github.com/keiffer213
|
||||
[@haipq07]: https://github.com/haipq07
|
||||
|
||||
|
||||
@@ -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