fyne-io / fyne

Cross platform GUI toolkit in Go inspired by Material Design
https://fyne.io/
Other
24.72k stars 1.37k forks source link

DocTabs Indicator remains visible after last tab is removed #4220

Closed pbrown12303 closed 1 year ago

pbrown12303 commented 1 year ago

Checklist

Describe the bug

If you remove all tabs from DocTabs, the selected indicator for the last tab remains visible.

How to reproduce

Run the attached test case. The first time will fail because the testdata is not present. Copy the failed files to the testdata folder and rerun - it will now run and pass all tests. Now compare emptyTabs.xml to afterTabRemoval.xml. The indicator rectangle which has a size of zero in emptyTabs now has an actual size and position in afterTabRemoval. Performing a DocTabs.SelectItem(-1) or DocTabs.Refresh() has no effect.

Screenshots

image

Example code

package container

import (
    "testing"
    "time"

    "fyne.io/fyne/v2"
    "fyne.io/fyne/v2/container"
    "fyne.io/fyne/v2/test"
    "fyne.io/fyne/v2/widget"
)

func TestEntryTextSize(t *testing.T) {
    tabs := container.NewDocTabs()
    tabs.Resize(fyne.NewSize(100, 100))
    tab1 := &container.TabItem{Text: "Test1", Content: widget.NewLabel("Test1")}
    time.Sleep(1000 * time.Millisecond)
    test.AssertObjectRendersToMarkup(t, "emptyTabs.xml", tabs)
    tabs.Append(tab1)
    time.Sleep(1000 * time.Millisecond)
    test.AssertObjectRendersToMarkup(t, "oneTab.xml", tabs)
    tabs.Select(tab1)
    time.Sleep(1000 * time.Millisecond)
    test.AssertObjectRendersToMarkup(t, "afterOneTabSelected.xml", tabs)
    tabs.Remove(tab1)
    time.Sleep(1000 * time.Millisecond)
    test.AssertObjectRendersToMarkup(t, "afterTabRemoval.xml", tabs)
    tabs.Refresh()
    time.Sleep(1000 * time.Millisecond)
    test.AssertObjectRendersToMarkup(t, "afterRefresh.xml", tabs)
    tabs.SelectIndex(-1)
    time.Sleep(1000 * time.Millisecond)
    test.AssertObjectRendersToMarkup(t, "afterSelectMinusOne.xml", tabs)
}

Fyne version

2.3.5

Go compiler version

1.21.0

Operating system and version

Windows 10

Additional Information

Here's the full test project, including testdata:

fyneDocTabsIndicatorTest.zip

andydotxyz commented 1 year ago

Thanks to @pbrown12303 this is now fixed on develop and will go into v2.4.1