diff options
author | Jo-Philipp Wich <jo@mein.io> | 2019-07-31 07:57:15 +0200 |
---|---|---|
committer | Jo-Philipp Wich <jo@mein.io> | 2019-08-01 16:47:19 +0200 |
commit | 89bcae20d0c0308bfbd9aab4b43fb6f8146b8f36 (patch) | |
tree | cceac7a12e088b74b236cd92b9065f7e90cddb4c /modules/luci-base/htdocs | |
parent | 27e414646149876f71865622f0d5d5118231d0f7 (diff) |
luci-base: ui.js: tabs: fix empty pane checking, allow alternative query root
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
Diffstat (limited to 'modules/luci-base/htdocs')
-rw-r--r-- | modules/luci-base/htdocs/luci-static/resources/ui.js | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/modules/luci-base/htdocs/luci-static/resources/ui.js b/modules/luci-base/htdocs/luci-static/resources/ui.js index fd413042f9..29233dec02 100644 --- a/modules/luci-base/htdocs/luci-static/resources/ui.js +++ b/modules/luci-base/htdocs/luci-static/resources/ui.js @@ -1589,8 +1589,14 @@ return L.Class.extend({ if (selected === null) { selected = this.getActiveTabId(groupId); - if (selected < 0 || selected >= panes.length) - selected = 0; + if (selected < 0 || selected >= panes.length || L.dom.isEmpty(panes[selected])) { + for (var i = 0; i < panes.length; i++) { + if (!L.dom.isEmpty(panes[i])) { + selected = i; + break; + } + } + } menu.childNodes[selected].classList.add('cbi-tab'); menu.childNodes[selected].classList.remove('cbi-tab-disabled'); @@ -1630,13 +1636,13 @@ return L.Class.extend({ return true; }, - updateTabs: function(ev) { - document.querySelectorAll('[data-tab-title]').forEach(function(pane) { + updateTabs: function(ev, root) { + (root || document).querySelectorAll('[data-tab-title]').forEach(function(pane) { var menu = pane.parentNode.previousElementSibling, tab = menu.querySelector('[data-tab="%s"]'.format(pane.getAttribute('data-tab'))), n_errors = pane.querySelectorAll('.cbi-input-invalid').length; - if (!pane.firstElementChild) { + if (L.dom.isEmpty(pane)) { tab.style.display = 'none'; tab.classList.remove('flash'); } |