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
- Create a QuickTabs instance with AJAX enabled and a Views tab that uses a contextual filter.
- Implement
hook_quicktabs_instance_alter()to set the view argument dynamically. - Load the page — the default tab renders correctly (alter fires via
getRenderArray()). - 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
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
Comment #2
loze commentedComment #4
loze commentedThis MR adds
$this->moduleHandler()->alter('quicktabs_instance', $qt)before$qt->getConfigurationData()in the controller.Also added a test module
quicktabs_alter_testwhich 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.