When using the grouped filters and selecting multiple values, only the last one is displayed and it has wrong value for thedata-remove-selector
attribute. The attribute contains string with label value e.g. 'A', but the argument in the URL for the filter contains key value from the group items e.g. '1'.
Add filter for example for the title of the entity. Use settings similar to the attached screenshots.
We should get values from the exposed input when the filter is grouped, because $filter->value
returns only one value (looks like the last selected one).
I've used such code in custom module to fix it:
/**
* Implements hook_batch_views_filters_summary_info_alter().
*/
function mymodule_views_filters_summary_info_alter(array &$info, FilterPluginBase $filter) {
// Fix grouped filter like 'Starting with'.
if ($filter->getPluginId() === 'string' &&
$filter->isAGroup() &&
!empty($filter->options['group_info']['group_items']) &&
is_array($filter->options['group_info']['group_items'])
) {
$exposed_input = $filter->view->getExposedInput();
$exposed_values = $exposed_input[$info['id']] ?? [];
$info['value'] = is_array($exposed_values) ? $exposed_values : [$filter->value];
$group_items = $filter->options['group_info']['group_items'];
$values = [];
foreach ($info['value'] as $index => $index_value) {
$values[] = [
'id' => $index,
'raw' => $index_value,
'value' => $group_items[$index]['value'],
];
}
$info['value'] = $values;
}
}
Maybe body of the function can be added to the ViewsFiltersSummary::buildFilterDefinition()
method to fix such cases by default?
Postponed: needs info
2.0
Code