From aaf4465146d67f79296bbfaf7ea8b22bc3b26809 Mon Sep 17 00:00:00 2001 From: Deeptanshu Sankhwar Date: Wed, 27 Nov 2024 10:22:54 -0700 Subject: [PATCH] refactor: improve readability of fallback logic for determining value --- modules/ui/fields/address.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/modules/ui/fields/address.js b/modules/ui/fields/address.js index 27cdbb1d17..af4024436d 100644 --- a/modules/ui/fields/address.js +++ b/modules/ui/fields/address.js @@ -55,7 +55,14 @@ export function uiFieldAddress(field, context) { dist = geoSphericalDistance(choice.loc, l); } - const value = resultProp && d.tags[resultProp] ? d.tags[resultProp] : d.tags.name; + const value = resultProp && d.tags[resultProp] + ? d.tags[resultProp] + : d.tags['name:en'] + ? d.tags['name:en'] // Fallback to English name + : d.tags.name + ? d.tags.name.split(';')[0].trim() // Use the first part of name (split by delimiter `;`) + : null; // Default to null if no valid value exists + let title = value; if (type === 'street') { title = `${addrField.t('placeholders.street')}: ${title}`;