backoffice: allow for links to open a specific tab (#65194)

This commit is contained in:
Frédéric Péters 2022-05-14 19:53:04 +02:00
parent 7be05db469
commit 6bb9dc4dc8
1 changed files with 8 additions and 0 deletions

View File

@ -7,6 +7,14 @@ $(function() {
});
$('h4.foldable.folded').next().hide();
/* focus tab from #open:<tab slug> anchor, used in documentation links
* to point to open panel */
if (document.location.hash && document.location.hash.indexOf('#open:') == 0) {
const $tab_button = $('#tab-' + document.location.hash.substring(6) + '[role=tab]');
if ($tab_button.length) {
$('.pk-tabs')[0].tabs.selectTab($tab_button[0]);
}
}
/* focus tab with error */
$('.form-with-tabs .error').first().closest('[role=tabpanel]').each(function(idx, elem) {
const $tab_button = $('[role=tab][aria-controls="' + $(elem).attr('id') + '"]');