Skip to content

Commit

Permalink
Move selected tab when number of tabs reduce
Browse files Browse the repository at this point in the history
When a  tab is deleted, the higher index tabs move down one. If the selected is above the one deleted move it also down one  to match the tabs
  • Loading branch information
adrianre12 committed Dec 18, 2020
1 parent 39f2a71 commit 3c8dde3
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion widget/tabcontainer.go
Expand Up @@ -122,10 +122,13 @@ func (c *TabContainer) Remove(item *TabItem) {

// RemoveIndex removes tab by index
func (c *TabContainer) RemoveIndex(index int) {
c.SetItems(append(c.Items[:index], c.Items[index+1:]...))
if c.current == index {
c.setTabIndex(-1)
}
if c.current > index {
c.setTabIndex(c.current - 1)
}
c.SetItems(append(c.Items[:index], c.Items[index+1:]...))
}

// SetItems sets the container’s items and refreshes.
Expand Down

0 comments on commit 3c8dde3

Please sign in to comment.