From 41418e57a589d5f37dc5381c224f26fbdb575ea6 Mon Sep 17 00:00:00 2001 From: Quincy Morgan Date: Wed, 20 May 2020 11:23:01 -0400 Subject: [PATCH] Fix issues with wikidata field searching and label updating --- modules/services/wikidata.js | 6 +++++- modules/ui/fields/wikidata.js | 10 ++++++---- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/modules/services/wikidata.js b/modules/services/wikidata.js index 4e7e53b05..7e6ea2b3d 100644 --- a/modules/services/wikidata.js +++ b/modules/services/wikidata.js @@ -85,8 +85,12 @@ export default { languagesToQuery: function() { + var localeCode = localizer.localeCode().toLowerCase(); + // HACK: en-us isn't a wikidata language. We should really be filtering by + // the languages known to be supported by wikidata. + if (localeCode === 'en-us') localeCode = 'en'; return utilArrayUniq([ - localizer.localeCode().toLowerCase(), + localeCode, localizer.languageCode().toLowerCase(), 'en' ]); diff --git a/modules/ui/fields/wikidata.js b/modules/ui/fields/wikidata.js index debeaa6d8..e2a2311e6 100644 --- a/modules/ui/fields/wikidata.js +++ b/modules/ui/fields/wikidata.js @@ -68,14 +68,12 @@ export function uiFieldWikidata(field, context) { .append('li') .attr('class', 'wikidata-search'); - _searchInput = searchRowEnter + searchRowEnter .append('input') .attr('type', 'text') .attr('id', field.domId) .style('flex', '1') - .call(utilNoAuto); - - _searchInput + .call(utilNoAuto) .on('focus', function() { var node = d3_select(this).node(); node.setSelectionRange(0, node.value.length); @@ -103,6 +101,10 @@ export function uiFieldWikidata(field, context) { if (_wikiURL) window.open(_wikiURL, '_blank'); }); + searchRow = searchRow.merge(searchRowEnter); + + _searchInput = searchRow.select('input'); + var wikidataProperties = ['description', 'identifier']; var items = list.selectAll('li.labeled-input')