don't select option on ambiguous multi-key radio fields

this matches the behaviour of a multi-selection: all matching options are still highlighted, but the radio-option is not set.

also fixes a minor bug with multi-selections not taking `<key> = no` properly into account

closes #8796
This commit is contained in:
Martin Raifer
2021-11-09 15:10:47 +01:00
parent 2f9285e011
commit f3e8852808
2 changed files with 10 additions and 5 deletions

File diff suppressed because one or more lines are too long

View File

@@ -265,13 +265,12 @@ export function uiFieldRadio(field, context) {
radio.tags = function(tags) {
radios.property('checked', function(d) {
function isOptionChecked(d) {
if (field.key) {
return tags[field.key] === d;
}
return !!(typeof tags[d] === 'string' && tags[d].toLowerCase() !== 'no');
});
}
function isMixed(d) {
if (field.key) {
@@ -280,13 +279,19 @@ export function uiFieldRadio(field, context) {
return Array.isArray(tags[d]);
}
radios.property('checked', function(d) {
return isOptionChecked(d) &&
(field.key || field.options.filter(isOptionChecked).length === 1);
});
labels
.classed('active', function(d) {
if (field.key) {
return (Array.isArray(tags[field.key]) && tags[field.key].includes(d))
|| tags[field.key] === d;
}
return Array.isArray(tags[d]) || !!(tags[d] && tags[d].toLowerCase() !== 'no');
return Array.isArray(tags[d]) && tags[d].some(v => typeof v === 'string' && v.toLowerCase() !== 'no') ||
!!(typeof tags[d] === 'string' && tags[d].toLowerCase() !== 'no');
})
.classed('mixed', isMixed)
.attr('title', function(d) {