From 3b793351f7876a64a98d3d5485dac9b5aa7f8604 Mon Sep 17 00:00:00 2001 From: Quincy Morgan <2046746+quincylvania@users.noreply.github.com> Date: Mon, 28 Sep 2020 15:28:07 -0400 Subject: [PATCH] Fix issue where names with en dashes couldn't be added (close #7536) Add `lang` attribute to brand name dropdown labels (re: #7963) --- modules/ui/fields/localized.js | 23 ++++------------------- 1 file changed, 4 insertions(+), 19 deletions(-) diff --git a/modules/ui/fields/localized.js b/modules/ui/fields/localized.js index 52d9480e6..578eda308 100644 --- a/modules/ui/fields/localized.js +++ b/modules/ui/fields/localized.js @@ -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 };