Skip to content

Commit

Permalink
refactor: improve readability of fallback logic for determining value
Browse files Browse the repository at this point in the history
  • Loading branch information
Deeptanshu Sankhwar committed Nov 27, 2024
1 parent 3bda6c7 commit aaf4465
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion modules/ui/fields/address.js
Original file line number Diff line number Diff line change
Expand Up @@ -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}`;
Expand Down

0 comments on commit aaf4465

Please sign in to comment.