mirror of
https://github.com/FoggedLens/iD.git
synced 2026-04-30 23:47:59 +02:00
refresh numeric fields on blur (#11027)
This commit is contained in:
@@ -43,12 +43,14 @@ _Breaking developer changes, which may affect downstream projects or sites that
|
||||
#### :camera: Street-Level
|
||||
#### :white_check_mark: Validation
|
||||
#### :bug: Bugfixes
|
||||
* Refresh numeric input fields after leaving focus with the value that is stored in the tag ([#11027])
|
||||
#### :earth_asia: Localization
|
||||
#### :hourglass: Performance
|
||||
#### :mortar_board: Walkthrough / Help
|
||||
#### :hammer: Development
|
||||
|
||||
[#10970]: https://github.com/openstreetmap/iD/pull/10970
|
||||
[#11027]: https://github.com/openstreetmap/iD/pull/11027
|
||||
|
||||
|
||||
# v2.34.0
|
||||
|
||||
@@ -414,19 +414,33 @@ export function uiFieldText(field, context) {
|
||||
// don't override multiple values with blank string
|
||||
if (!val && getVals(_tags).size > 1) return;
|
||||
|
||||
var displayVal = val;
|
||||
let displayVal = val;
|
||||
if (field.type === 'number' && val) {
|
||||
var numbers = val.split(';');
|
||||
numbers = numbers.map(function(v) {
|
||||
const numbers = val.split(';').map(v => {
|
||||
if (likelyRawNumberFormat.test(v)) {
|
||||
// input number likely in "raw" format
|
||||
return v;
|
||||
return {
|
||||
v,
|
||||
num: parseFloat(v),
|
||||
fractionDigits: v.includes('.') ? v.split('.')[1].length : 0
|
||||
};
|
||||
} else {
|
||||
// try to parse in localized number format
|
||||
return {
|
||||
v,
|
||||
num: parseLocaleFloat(v),
|
||||
fractionDigits: countDecimalPlaces(v)
|
||||
};
|
||||
}
|
||||
var num = parseLocaleFloat(v);
|
||||
const fractionDigits = countDecimalPlaces(v);
|
||||
return isFinite(num) ? clamped(num).toFixed(fractionDigits) : v;
|
||||
});
|
||||
val = numbers.join(';');
|
||||
val = numbers.map(({num, v, fractionDigits}) => {
|
||||
if (!isFinite(num)) return v;
|
||||
return clamped(num).toFixed(fractionDigits);
|
||||
}).join(';');
|
||||
displayVal = numbers.map(({num, v, fractionDigits}) => {
|
||||
if (!isFinite(num)) return v;
|
||||
return formatFloat(clamped(num), fractionDigits);
|
||||
}).join(';');
|
||||
}
|
||||
if (!onInput) utilGetSetValue(input, displayVal);
|
||||
t[field.key] = val || undefined;
|
||||
|
||||
Reference in New Issue
Block a user