mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-12-22 06:30:59 +01:00
Et2Tabs now auto-size from first tab contents when tabHeight property is not set
This commit is contained in:
parent
d8d9847012
commit
0f305e41a8
@ -72,7 +72,7 @@ export class Et2Tabs extends Et2InputWidget(SlTabGroup) implements et2_IResizeab
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the height for tabs
|
* Set the height for tabs
|
||||||
* Leave unset to size automatically
|
* Leave unset to size automatically from either parent height attribute, or height of first tabpanel
|
||||||
*/
|
*/
|
||||||
tabHeight: {type: String},
|
tabHeight: {type: String},
|
||||||
|
|
||||||
@ -215,6 +215,36 @@ export class Et2Tabs extends Et2InputWidget(SlTabGroup) implements et2_IResizeab
|
|||||||
|
|
||||||
// Create the tab DOM-Nodes
|
// Create the tab DOM-Nodes
|
||||||
this.createTabs(tabData);
|
this.createTabs(tabData);
|
||||||
|
|
||||||
|
// Use the height of the first tab if height not set
|
||||||
|
if(!this.tabHeight && tabData.length > 0)
|
||||||
|
{
|
||||||
|
const firstTab = tabData[0].contentDiv;
|
||||||
|
firstTab.updateComplete.then(async() =>
|
||||||
|
{
|
||||||
|
// Wait for children to load
|
||||||
|
let wait = [];
|
||||||
|
let walk = (widget) =>
|
||||||
|
{
|
||||||
|
if(widget.loading)
|
||||||
|
{
|
||||||
|
wait.push(widget.loading);
|
||||||
|
}
|
||||||
|
wait.push(widget.updateComplete);
|
||||||
|
widget.getChildren().forEach(child => walk(child));
|
||||||
|
}
|
||||||
|
walk(firstTab);
|
||||||
|
await Promise.all(wait);
|
||||||
|
|
||||||
|
const initial = firstTab.hasAttribute("active");
|
||||||
|
firstTab.setAttribute("active", '');
|
||||||
|
this.tabHeight = getComputedStyle(firstTab).height;
|
||||||
|
if(!initial)
|
||||||
|
{
|
||||||
|
firstTab.removeAttribute("active");
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_readTabs(tabData, tabs)
|
_readTabs(tabData, tabs)
|
||||||
|
Loading…
Reference in New Issue
Block a user