Skip to content

Commit 13e9173

Browse files
committed
feat(plugins): Improve auto-hide functionality for empty plugin tabs by ensuring proper visibility handling and Bootstrap integration
1 parent 7ef19b1 commit 13e9173

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

front/pluginsCore.php

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -438,13 +438,14 @@ function autoHideEmptyTabs(counts, prefixes) {
438438
const $pane = $(`#tabs-content-location > #${prefix}`);
439439

440440
if (total === 0) {
441-
// Hide the entire plugin tab
442-
$li.hide();
443-
$pane.removeClass('active').hide();
441+
// Hide the entire plugin tab and strip active from both nav item and pane
442+
$li.removeClass('active').hide();
443+
$pane.removeClass('active').css('display', '');
444444
} else {
445-
// Ensure visible (in case a previous filter hid it)
445+
// Ensure nav item visible (in case a previous filter hid it)
446446
$li.show();
447-
$pane.show();
447+
// Clear any inline display override so Bootstrap CSS controls pane visibility via .active
448+
$pane.css('display', '');
448449

449450
// Hide inner sub-tabs with zero count
450451
const subTabs = [
@@ -460,20 +461,19 @@ function autoHideEmptyTabs(counts, prefixes) {
460461
if (st.count === 0) {
461462
if ($subLi.hasClass('active')) activeSubHidden = true;
462463
$subLi.hide();
463-
$subPane.removeClass('active').hide();
464+
$subPane.removeClass('active').css('display', '');
464465
} else {
465466
$subLi.show();
466-
$subPane.show();
467+
$subPane.css('display', '');
467468
}
468469
});
469470

470471
// If the active inner sub-tab was hidden, activate the first visible one
472+
// via Bootstrap's tab lifecycle so shown.bs.tab fires for deferred DataTable init
471473
if (activeSubHidden) {
472-
const $firstVisibleSubLi = $pane.find('ul.nav-tabs li:visible').first();
473-
if ($firstVisibleSubLi.length) {
474-
$firstVisibleSubLi.addClass('active');
475-
const target = $firstVisibleSubLi.find('a').attr('href');
476-
$pane.find(target).addClass('active');
474+
const $firstVisibleSubA = $pane.find('ul.nav-tabs li:visible:first a');
475+
if ($firstVisibleSubA.length) {
476+
$firstVisibleSubA.tab('show');
477477
}
478478
}
479479
}

0 commit comments

Comments
 (0)