diff --git a/core/modules/views_ui/src/Form/Ajax/RearrangeFilter.php b/core/modules/views_ui/src/Form/Ajax/RearrangeFilter.php index 1b8e18d..64b0f3a 100644 --- a/core/modules/views_ui/src/Form/Ajax/RearrangeFilter.php +++ b/core/modules/views_ui/src/Form/Ajax/RearrangeFilter.php @@ -18,6 +18,13 @@ class RearrangeFilter extends ViewsFormBase { /** + * Constructs a new RearrangeFilter object. + */ + public function __construct($type = NULL) { + $this->setType($type); + } + + /** * {@inheritdoc} */ public function getFormKey() { @@ -208,6 +215,9 @@ public function buildForm(array $form, FormStateInterface $form_state) { '#value' => $this->t('Create new filter group'), '#id' => 'views-add-group', '#group' => 'add', + '#ajax' => array( + 'path' => \Drupal::request()->getRequestUri(), + ), ); return $form; @@ -259,16 +269,16 @@ public function submitForm(array &$form, FormStateInterface $form_state) { // If the #group property is set on the clicked button, that means we are // either adding or removing a group, not actually updating the filters. - $clicked_button = $form_state->get('clicked_button'); - if (!empty($clicked_button['#group'])) { - if ($clicked_button['#group'] == 'add') { + $triggering_element = $form_state->getTriggeringElement(); + if (!empty($triggering_element['#group'])) { + if ($triggering_element['#group'] == 'add') { // Add a new group $groups['groups'][] = 'AND'; } else { // Renumber groups above the removed one down. foreach (array_keys($groups['groups']) as $group_id) { - if ($group_id >= $clicked_button['#group']) { + if ($group_id >= $triggering_element['#group']) { $old_group = $group_id + 1; if (isset($groups['groups'][$old_group])) { $groups['groups'][$group_id] = $groups['groups'][$old_group];