title: JavaFX TabPane tabs don't update position
body: <p>I noticed that when adding and deleting tabs from a <code>TabPane</code>, it fails to match the position of the order of tabs in the underlying list. This only happens when at least one tab is hidden entirely due to the width of the parent. Here's some code that replicates the issue: </p>
  
  <pre><code>public class TabPaneTester extends Application {
      @Override
      public void start(Stage primaryStage) throws Exception {
          Scene scene = sizeScene();
          primaryStage.setMinHeight(200);
          primaryStage.setWidth(475);
          primaryStage.setScene(scene);
          primaryStage.show();
      }
  
      private Scene sizeScene(){
          TabPane tabPane = new TabPane();
          tabPane.setTabMinWidth(200);
          tabPane.getTabs().addAll(newTabs(3));
          Scene scene = new Scene(tabPane);
          scene.setOnKeyPressed(e -&gt; tabPane.getTabs().add(1, tabPane.getTabs().remove(0)));
          return scene;
      }
  
      private static Tab[] newTabs(int numTabs){
          Tab[] tabs = new Tab[numTabs];
          for(int i = 0; i &lt; numTabs; i++) {
              Label label = new Label("Tab Number " + (i + 1));
              Tab tab = new Tab();
              tab.setGraphic(label);
              tabs[i] = tab;
          }
          return tabs;
      }
  
      public static void main(String[] args) {
          launch();
      }
  
  }
  </code></pre>
  
  <p>When you press a key, it removes the first tab (at index 0) and puts it back at index 1, effectively swapping the first two tabs. However, when run the tabs don't actually visually swap (even though the tab switcher menu <em>does</em> switch their position). </p>
  
  <p><a href="https://i.stack.imgur.com/X5HIQ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/X5HIQ.png" alt="Tab position off"></a></p>
  
  <p>If you change the width of the screen to include even a pixel of the third tab that was hidden (replace 475 with 500), it works as intended. Any clues as to how to fix this?</p>