Unverified Commit 295bf67c authored by fenstrat's avatar fenstrat Committed by markcarver

Issue #2985470 by fenstrat: Fragment links to children elements in closed vertical tabs don't work

parent 97e3d9fd
......@@ -6,6 +6,23 @@
(function ($, window, Drupal, drupalSettings) {
"use strict";
/**
* Show the parent vertical tab pane of a targeted page fragment.
*
* In order to make sure a targeted element inside a vertical tab pane is
* visible on a hash change or fragment link click, show all parent panes.
*
* @param {jQuery.Event} e
* The event triggered.
* @param {jQuery} $target
* The targeted node as a jQuery object.
*/
var handleFragmentLinkClickOrHashChange = function handleFragmentLinkClickOrHashChange(e, $target) {
$target.parents('.vertical-tabs-pane').each(function (index, pane) {
$(pane).data('verticalTab').focus();
});
};
/**
* This script transforms a set of details into a stack of vertical
* tabs. Another tab pane can be selected by clicking on the respective
......@@ -26,6 +43,11 @@
return;
}
/**
* Binds a listener to handle fragment link clicks and URL hash changes.
*/
$('body').once('vertical-tabs-fragments').on('formFragmentLinkClickOrHashChange.verticalTabs', handleFragmentLinkClickOrHashChange);
$(context).find('[data-vertical-tabs-panes]').once('vertical-tabs').each(function () {
var $this = $(this).addClass('tab-content vertical-tabs-panes');
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment