Skip to content

Commit

Permalink
keep height of all panes consistent
Browse files Browse the repository at this point in the history
  • Loading branch information
titusfortner committed Nov 17, 2023
1 parent f84d00f commit 48f9160
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions static/js/tabpane-persist.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,26 @@ const _tdStoragePersistKey = (tabKey) =>

const _tdSupportsLocalStorage = () => typeof Storage !== 'undefined';

function adjustTabContentHeights() {
const tabPanes = document.querySelectorAll('.tab-content');

tabPanes.forEach(pane => {
let maxHeight = 0;
const tabBody = pane.querySelectorAll('.tab-body');

tabBody.forEach(tabContent => {
tabContent.style.display = 'block'; // Temporarily show the tab content
maxHeight = Math.max(maxHeight, tabContent.clientHeight);
tabContent.style.display = ''; // Reset the display property
});

tabBody.forEach(tabContent => {
tabContent.style.height = maxHeight + 'px';
});
});
}


// Helpers

function tdPersistKey(key, value) {
Expand Down Expand Up @@ -93,6 +113,9 @@ function tdGetAndActivatePersistedTabs(tabs) {
tdActivateTabsWithKey(key);
});

// Adjust tab content heights
adjustTabContentHeights();

return key_ageList;
}

Expand Down

0 comments on commit 48f9160

Please sign in to comment.