Skip to content

NewTreeWithData Rendering Issue #4346

Closed
@BieHDC

Description

Checklist

  • I have searched the issue tracker for open issues that relate to the same problem, before opening a new one.
  • This issue only relates to a single bug. I will open new issues for any other problems.

Describe the bug

When making a widget.NewTreeWithData with the binding to a tree fyne sometimes doesnt render items above the selected one except for one above. See Video.

How to reproduce

  1. Run Example Code
  2. Select the 2nd item, then the 3rd, then the 4th
  3. If the bug didnt trigger, close the application and do 2. again (See Video)

Screenshots

minex.mp4

Example code

package main

import (
	"fyne.io/fyne/v2"
	"fyne.io/fyne/v2/app"
	"fyne.io/fyne/v2/container"
	"fyne.io/fyne/v2/data/binding"
	"fyne.io/fyne/v2/widget"
)

func main() {
	a := app.New()
	w := a.NewWindow("BUG DEMO")
	w.Resize(fyne.NewSize(800, 600))
	w.SetContent(makeMain(a, w))
	w.Show()
	a.Run()
}

func makeMain(a fyne.App, w fyne.Window) fyne.CanvasObject {
	tree := binding.NewStringTree()
	treewg := widget.NewTreeWithData(
		tree,
		func(_ bool) fyne.CanvasObject {
			return widget.NewLabel("example str")
		},
		func(data binding.DataItem, _ bool, obj fyne.CanvasObject) {
			l := obj.(*widget.Label)
			d, err := data.(binding.String).Get()
			if err != nil {
				panic(err)
			}
			l.SetText(d)
		},
	)

	for _, str := range []string{"aaa", "bbb", "ccc", "ddd", "eee"} {
		tree.Append(binding.DataTreeRootID, str, str+str)
	}

	return container.NewPadded(treewg)
}

Fyne version

2.4.1

Go compiler version

1.21.3

Operating system and version

linux/amd64

Additional Information

Does NOT happen with widget.NewListWithData

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions