diff --git a/modules/custom/az_finder/az_finder.services.yml b/modules/custom/az_finder/az_finder.services.yml index 01e9347a70..2707548a1a 100644 --- a/modules/custom/az_finder/az_finder.services.yml +++ b/modules/custom/az_finder/az_finder.services.yml @@ -20,3 +20,5 @@ services: logger.channel.az_finder: parent: logger.channel_base arguments: ['az_finder'] + az_finder.ajax_response_subscriber: + class: Drupal\az_finder\EventSubscriber\AZFinderAjaxResponseSubscriber diff --git a/modules/custom/az_finder/src/EventSubscriber/AZFinderAjaxResponseSubscriber.php b/modules/custom/az_finder/src/EventSubscriber/AZFinderAjaxResponseSubscriber.php new file mode 100644 index 0000000000..3b2aa3d356 --- /dev/null +++ b/modules/custom/az_finder/src/EventSubscriber/AZFinderAjaxResponseSubscriber.php @@ -0,0 +1,51 @@ +getResponse(); + + // Only modify commands if this is an AJAX response for a view using + // Quickstart Exposed Filters for the exposed form. + if ($response instanceof ViewAjaxResponse) { + $exposedForm = $response->getView()->display_handler->getOption('exposed_form'); + if (is_array($exposedForm) && $exposedForm['type'] === 'az_better_exposed_filters') { + $commands = &$response->getCommands(); + foreach ($commands as $key => $value) { + if ($value['command'] === 'scrollTop') { + unset($commands[$key]); + // Only one scrollTop command is expected. + return; + } + } + } + } + } + +}