mirror of
https://github.com/jokob-sk/NetAlertX.git
synced 2026-04-15 22:51:37 -07:00
feat(plugins): Improve auto-hide functionality for empty plugin tabs by ensuring proper visibility handling and Bootstrap integration
This commit is contained in:
+12
-12
@@ -438,13 +438,14 @@ function autoHideEmptyTabs(counts, prefixes) {
|
|||||||
const $pane = $(`#tabs-content-location > #${prefix}`);
|
const $pane = $(`#tabs-content-location > #${prefix}`);
|
||||||
|
|
||||||
if (total === 0) {
|
if (total === 0) {
|
||||||
// Hide the entire plugin tab
|
// Hide the entire plugin tab and strip active from both nav item and pane
|
||||||
$li.hide();
|
$li.removeClass('active').hide();
|
||||||
$pane.removeClass('active').hide();
|
$pane.removeClass('active').css('display', '');
|
||||||
} else {
|
} else {
|
||||||
// Ensure visible (in case a previous filter hid it)
|
// Ensure nav item visible (in case a previous filter hid it)
|
||||||
$li.show();
|
$li.show();
|
||||||
$pane.show();
|
// Clear any inline display override so Bootstrap CSS controls pane visibility via .active
|
||||||
|
$pane.css('display', '');
|
||||||
|
|
||||||
// Hide inner sub-tabs with zero count
|
// Hide inner sub-tabs with zero count
|
||||||
const subTabs = [
|
const subTabs = [
|
||||||
@@ -460,20 +461,19 @@ function autoHideEmptyTabs(counts, prefixes) {
|
|||||||
if (st.count === 0) {
|
if (st.count === 0) {
|
||||||
if ($subLi.hasClass('active')) activeSubHidden = true;
|
if ($subLi.hasClass('active')) activeSubHidden = true;
|
||||||
$subLi.hide();
|
$subLi.hide();
|
||||||
$subPane.removeClass('active').hide();
|
$subPane.removeClass('active').css('display', '');
|
||||||
} else {
|
} else {
|
||||||
$subLi.show();
|
$subLi.show();
|
||||||
$subPane.show();
|
$subPane.css('display', '');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// If the active inner sub-tab was hidden, activate the first visible one
|
// If the active inner sub-tab was hidden, activate the first visible one
|
||||||
|
// via Bootstrap's tab lifecycle so shown.bs.tab fires for deferred DataTable init
|
||||||
if (activeSubHidden) {
|
if (activeSubHidden) {
|
||||||
const $firstVisibleSubLi = $pane.find('ul.nav-tabs li:visible').first();
|
const $firstVisibleSubA = $pane.find('ul.nav-tabs li:visible:first a');
|
||||||
if ($firstVisibleSubLi.length) {
|
if ($firstVisibleSubA.length) {
|
||||||
$firstVisibleSubLi.addClass('active');
|
$firstVisibleSubA.tab('show');
|
||||||
const target = $firstVisibleSubLi.find('a').attr('href');
|
|
||||||
$pane.find(target).addClass('active');
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user