From 4578691d23ba1b675cecdf82d3f4494d0d482123 Mon Sep 17 00:00:00 2001 From: Javier Godoy <11554739+javier-godoy@users.noreply.github.com> Date: Mon, 8 Jul 2024 16:46:06 -0300 Subject: [PATCH] fix: ensure selected tab from overflow is correctly displayed Close #16 --- .../resources/META-INF/frontend/fcEnhancedTabs/connector.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/resources/META-INF/frontend/fcEnhancedTabs/connector.js b/src/main/resources/META-INF/frontend/fcEnhancedTabs/connector.js index b7c351b..3e24aca 100644 --- a/src/main/resources/META-INF/frontend/fcEnhancedTabs/connector.js +++ b/src/main/resources/META-INF/frontend/fcEnhancedTabs/connector.js @@ -64,9 +64,9 @@ // move the selected tab out of the overflow button buttons = tabs._buttons; const selectedIndex = buttons.findIndex(e=>e.item.component && e.item.component.querySelector('vaadin-tab[selected]')); - const overflowIndex = buttons.findIndex(e=>e.style.visibility); - if (selectedIndex>=overflowIndex && overflowIndex>0) { - buttons[0].parentElement.insertBefore(buttons[selectedIndex], buttons[overflowIndex-1]); + let overflowIndex = buttons.findIndex(e=>e.style.visibility); + while (selectedIndex>=overflowIndex && overflowIndex>0 && buttons[selectedIndex].style.visibility) { + buttons[0].parentElement.insertBefore(buttons[selectedIndex], buttons[overflowIndex--]); __detectOverflow(); buttons[selectedIndex]._position = selectedIndex; }