luci-base: ui.js: ignore description when checking for empty tab panes
authorJo-Philipp Wich <jo@mein.io>
Tue, 20 Aug 2019 11:33:08 +0000 (13:33 +0200)
committerJo-Philipp Wich <jo@mein.io>
Tue, 10 Sep 2019 13:28:16 +0000 (15:28 +0200)
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
modules/luci-base/htdocs/luci-static/resources/ui.js

index 77cef53964f7dfbde7290db88f98636fbf956348..ad1547fee2648f7b0c7cbdd511edc0d424182471 100644 (file)
@@ -1628,7 +1628,7 @@ return L.Class.extend({
                                    active = pane.getAttribute('data-tab-active') === 'true';
 
                                menu.appendChild(E('li', {
-                                       'style': L.dom.isEmpty(pane) ? 'display:none' : null,
+                                       'style': this.isEmptyPane(pane) ? 'display:none' : null,
                                        'class': active ? 'cbi-tab' : 'cbi-tab-disabled',
                                        'data-tab': name
                                }, E('a', {
@@ -1645,9 +1645,9 @@ return L.Class.extend({
                        if (selected === null) {
                                selected = this.getActiveTabId(panes[0]);
 
-                               if (selected < 0 || selected >= panes.length || L.dom.isEmpty(panes[selected])) {
+                               if (selected < 0 || selected >= panes.length || this.isEmptyPane(panes[selected])) {
                                        for (var i = 0; i < panes.length; i++) {
-                                               if (!L.dom.isEmpty(panes[i])) {
+                                               if (!this.isEmptyPane(panes[i])) {
                                                        selected = i;
                                                        break;
                                                }
@@ -1662,6 +1662,10 @@ return L.Class.extend({
                        }
                },
 
+               isEmptyPane: function(pane) {
+                       return L.dom.isEmpty(pane, function(n) { return n.classList.contains('cbi-tab-descr') });
+               },
+
                getPathForPane: function(pane) {
                        var path = [], node = null;
 
@@ -1712,7 +1716,7 @@ return L.Class.extend({
                },
 
                updateTabs: function(ev, root) {
-                       (root || document).querySelectorAll('[data-tab-title]').forEach(function(pane) {
+                       (root || document).querySelectorAll('[data-tab-title]').forEach(L.bind(function(pane) {
                                var menu = pane.parentNode.previousElementSibling,
                                    tab = menu ? menu.querySelector('[data-tab="%s"]'.format(pane.getAttribute('data-tab'))) : null,
                                    n_errors = pane.querySelectorAll('.cbi-input-invalid').length;
@@ -1720,7 +1724,7 @@ return L.Class.extend({
                                if (!menu || !tab)
                                        return;
 
-                               if (L.dom.isEmpty(pane)) {
+                               if (this.isEmptyPane(pane)) {
                                        tab.style.display = 'none';
                                        tab.classList.remove('flash');
                                }
@@ -1738,7 +1742,7 @@ return L.Class.extend({
                                        tab.removeAttribute('data-errors');
                                        tab.removeAttribute('data-tooltip');
                                }
-                       });
+                       }, this));
                },
 
                switchTab: function(ev) {