Properly hide the input field on semicombos when there aren't enough characters remaining to add another value (re: #6817)

This commit is contained in:
Quincy Morgan
2020-01-27 16:35:15 -05:00
parent 17ae12b3d7
commit 6dc02d7f22
+13 -3
View File
@@ -432,9 +432,18 @@ export function uiFieldCombo(field, context) {
};
});
var currLength = arr.join(';').length;
// limit the input length to the remaining available characters
maxLength = services.osm.maxCharsForTagValue() - (tags[field.key] || '').length;
maxLength = services.osm.maxCharsForTagValue() - currLength;
if (currLength > 0) {
// account for the separator if a new value will be appended to existing
maxLength -= 1;
}
}
// a negative maxlength doesn't make sense
maxLength = Math.max(0, maxLength);
// Exclude existing multikeys from combo options..
var available = objectDifference(_comboData, _multiData);
@@ -443,8 +452,9 @@ export function uiFieldCombo(field, context) {
// Hide 'Add' button if this field uses fixed set of
// translateable optstrings and they're all currently used,
// or if the field is already at its character limit
container.selectAll('.combobox-input, .combobox-caret')
.classed('hide', (optstrings && !available.length) || !maxLength);
var hideAdd = (optstrings && !available.length) || maxLength <= 0;
container.selectAll('.chiplist .input-wrap')
.style('display', hideAdd ? 'none' : null);
// Render chips