Fixed bug with tabs

pull/2/head
ilian.iliev 2023-03-20 09:50:42 +02:00
parent f37063f06f
commit 64dfaeb8d5
1 changed files with 15 additions and 8 deletions

View File

@ -83,20 +83,27 @@ const StateController = (function () {
}
}
function storeTab() {
localStorage.setItem(LS_PREFIX + 'tab', this.textContent);
bindTabEvents();
}
function bindTabEvents() {
const tabs = gradioApp().querySelectorAll('#tabs > div:first-child button');
tabs.forEach(tab => { // dirty hack here
tab.removeEventListener('click', storeTab);
tab.addEventListener('click', storeTab);
});
return tabs;
}
function restoreTabs(config) {
if (! config.hasSetting('tabs')) {
return;
}
const tabs = gradioApp().querySelectorAll('#tabs > div:first-child button');
tabs.forEach(tab => {
tab.addEventListener('click', function () {
localStorage.setItem(LS_PREFIX + 'tab', this.textContent);
});
});
const tabs = bindTabEvents();
const value = localStorage.getItem(LS_PREFIX + 'tab');
if (value) {