mirror of
https://github.com/FoggedLens/iD.git
synced 2026-05-14 13:18:15 +02:00
Fix issue where names with en dashes couldn't be added (close #7536)
Add `lang` attribute to brand name dropdown labels (re: #7963)
This commit is contained in:
@@ -259,7 +259,6 @@ export function uiFieldLocalized(field, context) {
|
||||
var preset = presetManager.match(latest, context.graph());
|
||||
if (preset && preset.suggestion) return; // already accepted
|
||||
|
||||
// note: here we are testing against "decorated" names, i.e. 'Starbucks – Cafe'
|
||||
var name = utilGetSetValue(input).trim();
|
||||
var matched = allSuggestions.filter(function(s) { return name === s.name(); });
|
||||
|
||||
@@ -292,25 +291,10 @@ export function uiFieldLocalized(field, context) {
|
||||
}
|
||||
|
||||
|
||||
// user hit escape, clean whatever preset name appears after the last ' – '
|
||||
// user hit escape
|
||||
function cancelBrand() {
|
||||
var name = utilGetSetValue(input);
|
||||
var clean = cleanName(name);
|
||||
if (clean !== name) {
|
||||
utilGetSetValue(input, clean);
|
||||
dispatch.call('change', this, { name: clean });
|
||||
}
|
||||
}
|
||||
|
||||
// Remove whatever is after the last ' – '
|
||||
// NOTE: split/join on en-dash, not a hyphen (to avoid conflict with fr - nl names in Brussels etc)
|
||||
function cleanName(name) {
|
||||
var parts = name.split(' – ');
|
||||
if (parts.length > 1) {
|
||||
parts.pop();
|
||||
name = parts.join(' – ');
|
||||
}
|
||||
return name;
|
||||
dispatch.call('change', this, { name: name });
|
||||
}
|
||||
|
||||
|
||||
@@ -340,8 +324,9 @@ export function uiFieldLocalized(field, context) {
|
||||
|
||||
if (dist < 1 || (matchesPreset && dist < 3)) {
|
||||
var obj = {
|
||||
value: s.name(),
|
||||
title: name,
|
||||
value: name,
|
||||
display: s.nameLabel() + (subtitle ? ' – ' + s.subtitleLabel() : ''),
|
||||
suggestion: s,
|
||||
dist: dist + (matchesPreset ? 0 : 1) // penalize if not matched preset
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user