   setTabOffset: (offset) ->
     return if !@props.children?
     nowKey = @activeKey()
+    childrenCount = React.Children.count @props.children
     React.Children.forEach @props.children, (child, index) =>
       if child.key == nowKey
-        nextIndex = (index+offset+@props.children.length) % @props.children.length
-        @setNewKey @props.children[nextIndex].key
+        nextIndex = (index+offset+childrenCount) % childrenCount
+        # Always use the same method to preserve the definition of index
+        React.Children.forEach @props.children, (child_, index_) =>
+          if index_ == nextIndex
+            @setNewKey child_.key
 
   render: ->
     onTheLeft = true

            {shipview.displayName}
          </NavItem>
          <NavItem key='plugin' eventKey={activePluginName} onSelect={@handleSelect}>
            {plugin?.displayName || defaultPluginTitle}
          </NavItem>
          <NavDropdown id='plugin-dropdown' pullRight title=''
             onSelect={@handleSelectDropdown}>
          {
            @state.plugins.map (plugin, index) =>
              <MenuItem key={plugin.name} eventKey={plugin.name} onSelect={plugin.handleClick}>
                {plugin.displayName}
              </MenuItem>
          }
          {
            if @state.plugins.length == 0
              defaultPluginContents
          }
          </NavDropdown>
          <NavItem key='settings' eventKey='settings' className="tab-narrow">
            <FontAwesome key={0} name='cog' />
          </NavItem>
        </Nav>
        <TabContentsUnion ref='mainTabUnion'
          onChange={(key) => @setState {activeMainTab: key}}>
          <div id={mainview.name} className="poi-app-tabpane" key='mainView'>
            <mainview.reactClass />

        </div>
        <div className="no-scroll">
          <Nav bsStyle="tabs" onSelect={@handleSelectDropdown}>
            <NavDropdown id='plugin-dropdown' pullRight
              title={activePlugin?.displayName || defaultPluginTitle}>
            {pluginDropdownContents}
            </NavDropdown>
          </Nav>
          <TabContentsUnion ref='tabKeyUnion'>
            {pluginContents}
          </TabContentsUnion>
        </div>
      </div>
