From aa0a4400ad2c8d7a1ee4621fde3746b0e33d20b6 Mon Sep 17 00:00:00 2001 From: Quincy Morgan Date: Tue, 3 Dec 2019 15:23:41 -0500 Subject: [PATCH] Don't remove moreFields UI when clearing a value (close #6580) --- modules/ui/field.js | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/modules/ui/field.js b/modules/ui/field.js index 18ede7f9b..ecd840df3 100644 --- a/modules/ui/field.js +++ b/modules/ui/field.js @@ -66,7 +66,7 @@ export function uiField(context, presetField, entity, options) { } - function isPresent() { + function tagsContainFieldKey() { return field.keys.some(function(key) { if (field.type === 'multiCombo') { for (var tagKey in _tags) { @@ -223,7 +223,7 @@ export function uiField(context, presetField, entity, options) { container .classed('locked', _locked) .classed('modified', isModified()) - .classed('present', isPresent()); + .classed('present', tagsContainFieldKey()); // show a tip and lock icon if the field is locked @@ -254,6 +254,15 @@ export function uiField(context, presetField, entity, options) { field.tags = function(val) { if (!arguments.length) return _tags; _tags = val; + + if (tagsContainFieldKey() && !_show) { + // always show a field if it has a value to display + _show = true; + if (!field.impl) { + createField(); + } + } + return field; }; @@ -279,14 +288,14 @@ export function uiField(context, presetField, entity, options) { // A shown field has a visible UI, a non-shown field is in the 'Add field' dropdown field.isShown = function() { - return _show || isPresent(); + return _show; }; // An allowed field can appear in the UI or in the 'Add field' dropdown. // A non-allowed field is hidden from the user altogether field.isAllowed = function() { - if (!entity || isPresent()) return true; // a field with a value should always display + if (!entity || tagsContainFieldKey()) return true; // a field with a value should always display var latest = context.hasEntity(entity.id); // check the most current copy of the entity if (!latest) return true;