Skip to content

Commit

Permalink
Fix postion of line during deletion
Browse files Browse the repository at this point in the history
  • Loading branch information
andydotxyz committed Jul 11, 2023
1 parent 36a4286 commit ef93b2b
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
5 changes: 5 additions & 0 deletions container/doctabs.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
16 changes: 16 additions & 0 deletions container/doctabs_internal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

0 comments on commit ef93b2b

Please sign in to comment.