From 84ba852993612701060410e7497c3c8d5f6f9c11 Mon Sep 17 00:00:00 2001 From: Ansuel Smith Date: Tue, 24 Nov 2020 02:36:50 +0100 Subject: [PATCH] luci-base: delay cbi-tab-active event on tab init Delay the cbi-tab-active custom event so any eventListner attached to the tab doesn't miss the first event. Signed-off-by: Ansuel Smith --- modules/luci-base/htdocs/luci-static/resources/ui.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/modules/luci-base/htdocs/luci-static/resources/ui.js b/modules/luci-base/htdocs/luci-static/resources/ui.js index 77074d5075..e35a26a8ba 100644 --- a/modules/luci-base/htdocs/luci-static/resources/ui.js +++ b/modules/luci-base/htdocs/luci-static/resources/ui.js @@ -3597,9 +3597,11 @@ var UI = baseclass.extend(/** @lends LuCI.ui.prototype */ { this.setActiveTabId(panes[selected], selected); } - panes[selected].dispatchEvent(new CustomEvent('cbi-tab-active', { - detail: { tab: panes[selected].getAttribute('data-tab') } - })); + requestAnimationFrame(L.bind(function(pane) { + pane.dispatchEvent(new CustomEvent('cbi-tab-active', { + detail: { tab: pane.getAttribute('data-tab') } + })); + }, this, panes[selected])); this.updateTabs(group); },