fyne-io / fyne

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

The "tree" disappears in the "split" after a certain time #4683

Open GoHippo opened 8 months ago

GoHippo commented 8 months ago

Checklist

Describe the bug

I go to the second tab in the "tab", there I open the "branch" in the "tree", which is located on the left side of the "split". Then I go back to the first tab and wait a little more than 1 minute. Then I check the second tab, and the "tree" disappeared there. If you touch the separator in "split", then "tree" appears.

How to reproduce

  1. Go to the second tab in the "tab".
  2. Open branch" in "tree".
  3. Go to the first tab in the "tab".
  4. Wait 1-1.5 minutes.
  5. Go to the second tab in the "tab".

Screenshots

No response

Example code

func main() {
    app := app.New()
    win := app.NewWindow("win")
    win.Resize(fyne.NewSize(500, 600))
    win.CenterOnScreen()

    tree := widget.NewTreeWithStrings(map[string][]string{
        "":       {"Result"},
        "Result": {"none"},
    })
    split := container.NewHSplit(tree, container.NewCenter())

    tab := container.NewAppTabs(
        container.NewTabItem("menu", container.NewCenter()),
        container.NewTabItem("list",  split),
    )
    tab.SetTabLocation(container.TabLocationTop)

    win.SetContent(tab)
    win.ShowAndRun()
}

Fyne version

v2.4.4

Go compiler version

1.21.6

Operating system and version

Windows 10

Additional Information

https://github.com/fyne-io/fyne/assets/17017191/73b7c65c-bd42-409e-896c-61640ece4c9f

andydotxyz commented 8 months ago

Looking at eliminating the possible causes can you please remove any container.NewBorder(nil, nil, nil, nil as it adds nothing - widgets will fill the space by default.

williambrode commented 6 months ago

I'm having this issue too and tried fruitlessly to figure out what was going on via the debugger for a few hours. In my case too its a TabItem containing an HSplit containing a Tree. My workaround which appears to fix it is this:

        tabs.OnSelected = func(tab *container.TabItem) {
        if tab == treeTab {
            // Hack to work around https://github.com/fyne-io/fyne/issues/4683
            treeTab.Content.Resize(fyne.NewSize(treeTab.Content.Size().Width+10, treeTab.Content.Size().Height+10))
        }
    }