Problem/Motivation

QuickTabsInstance::getRenderArray() calls hook_quicktabs_instance_alter() before rendering (line 222), but QuickTabsController::ajaxContent() loads the
entity and renders directly without calling it (lines 62-65). Modules that use the alter to set view arguments or modify tab configuration have their changes ignored on AJAX-loaded tabs.

Steps to reproduce

  1. Create a QuickTabs instance with AJAX enabled and a Views tab that uses a contextual filter.
  2. Implement hook_quicktabs_instance_alter() to set the view argument dynamically.
  3. Load the page — the default tab renders correctly (alter fires via getRenderArray()).
  4. Click a non-default tab — the AJAX-loaded tab ignores the alter and renders with no argument.

Proposed resolution

Inject ModuleHandlerInterface into QuickTabsController and call the alter before reading configuration data in ajaxContent():

$this->moduleHandler->alter('quicktabs_instance', $qt);                                                                                                                                 
  $configuration_data = $qt->getConfigurationData();

API changes

None. Existing hook_quicktabs_instance_alter() will now fire on AJAX tab loads as well as server-rendered loads.

Issue fork quicktabs-3606674

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

loze created an issue. See original summary.

loze’s picture

Issue summary: View changes

loze’s picture

Status: Active » Needs review

This MR adds $this->moduleHandler()->alter('quicktabs_instance', $qt) before $qt->getConfigurationData() in the controller.

Also added a test module quicktabs_alter_test which implements the alter hook and tracks calls via State API.
Three kernel tests verify: the alter fires on server render, the alter fires on the AJAX path, and the altered configuration is reflected in the rendered output.