diff --git a/container/doctabs.go b/container/doctabs.go index 854201e614..4fc8a482ce 100644 --- a/container/doctabs.go +++ b/container/doctabs.go @@ -244,7 +244,12 @@ func (r *docTabsRenderer) Layout(size fyne.Size) { r.updateCreateTab() r.updateTabs() r.layout(r.docTabs, size) + + // lay out buttons before updating indicator, which is relative to their position + buttons := r.scroller.Content.(*fyne.Container) + buttons.Layout.Layout(buttons.Objects, buttons.Size()) r.updateIndicator(r.docTabs.transitioning()) + if r.docTabs.transitioning() { r.docTabs.setTransitioning(false) } diff --git a/container/doctabs_internal_test.go b/container/doctabs_internal_test.go index 202faf1d04..0f51c3b425 100644 --- a/container/doctabs_internal_test.go +++ b/container/doctabs_internal_test.go @@ -30,3 +30,19 @@ func TestDocTabs_tabButtonRenderer_SetText(t *testing.T) { renderer = cache.Renderer(button).(*tabButtonRenderer) assert.Equal(t, "Replace", renderer.label.Text) } + +func TestDocTabs_tabButtonRenderer_Remove(t *testing.T) { + items := []*TabItem{{Text: "1", Content: widget.NewLabel("Content1")}, + {Text: "2", Content: widget.NewLabel("Content2")}, + {Text: "3", Content: widget.NewLabel("Content3")}} + tabs := NewDocTabs(items...) + tabs.Resize(fyne.NewSize(100, 100)) + tabRenderer := cache.Renderer(tabs).(*docTabsRenderer) + + tabs.SelectIndex(1) + pos := tabRenderer.indicator.Position() + tabs.RemoveIndex(0) + assert.Equal(t, 0, tabs.SelectedIndex()) + + assert.Less(t, tabRenderer.indicator.Position().X, pos.X) +}