@@ -10,14 +10,16 @@ window.addEventListener("load", (e) => {
1010 warnWithoutSaving ( ) ;
1111
1212 tabNavigation ( ) ;
13+
14+ tabNavigation ( "fieldset-" ) ;
1315} ) ;
1416
1517/*************************************************************
1618 * Move not visible tab items to dropdown
1719 *************************************************************/
18- function tabNavigation ( ) {
19- const itemsDropdown = document . getElementById ( "tabs-dropdown" ) ;
20- const itemsList = document . getElementById ( "tabs-items" ) ;
20+ function tabNavigation ( prefix = "" ) {
21+ const itemsDropdown = document . getElementById ( prefix + "tabs-dropdown" ) ;
22+ const itemsList = document . getElementById ( prefix + "tabs-items" ) ;
2123 const widths = [ ] ;
2224
2325 if ( ! itemsDropdown || ! itemsList ) {
@@ -32,7 +34,7 @@ function tabNavigation() {
3234
3335 function handleTabNavigationResize ( ) {
3436 const contentWidth = document . getElementById ( "content" ) . offsetWidth ;
35- const tabsWidth = document . getElementById ( "tabs-wrapper" ) . scrollWidth ;
37+ const tabsWidth = document . getElementById ( prefix + "tabs-wrapper" ) . scrollWidth ;
3638 const availableWidth =
3739 itemsList . parentElement . offsetWidth - itemsList . offsetWidth - 48 ;
3840
@@ -47,7 +49,7 @@ function tabNavigation() {
4749 // If there is still not enough space, move the last item to the dropdown again
4850 if (
4951 document . getElementById ( "content" ) . offsetWidth <
50- document . getElementById ( "tabs-wrapper" ) . scrollWidth
52+ document . getElementById ( prefix + "tabs-wrapper" ) . scrollWidth
5153 ) {
5254 handleTabNavigationResize ( ) ;
5355 }
@@ -70,6 +72,14 @@ function tabNavigation() {
7072 itemsDropdown . parentElement . classList . add ( "hidden" ) ;
7173 } else {
7274 itemsDropdown . parentElement . classList . remove ( "hidden" ) ;
75+
76+ // After adding the dropdown item, check again if we need to move items
77+ if (
78+ document . getElementById ( "content" ) . offsetWidth <
79+ document . getElementById ( prefix + "tabs-wrapper" ) . scrollWidth
80+ ) {
81+ handleTabNavigationResize ( ) ;
82+ }
7383 }
7484 }
7585}
0 commit comments