Skip to content

Commit

Permalink
Fixup tap scrolls to top on first selection
Browse files Browse the repository at this point in the history
  • Loading branch information
andydotxyz committed Jan 29, 2025
1 parent 3795a68 commit 6fa30e0
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
3 changes: 2 additions & 1 deletion widget/tree.go
Original file line number Diff line number Diff line change
Expand Up @@ -878,7 +878,8 @@ func (n *treeNode) Tapped(*fyne.PointEvent) {
n.tree.Select(n.uid)
if !fyne.CurrentDevice().IsMobile() {
canvas := fyne.CurrentApp().Driver().CanvasForObject(n.tree)
if canvas != nil {
if canvas != nil && canvas.Focused() != n.tree {
n.tree.currentFocus = n.uid
canvas.Focus(n.tree)
}
n.tree.currentFocus = n.uid
Expand Down
2 changes: 2 additions & 0 deletions widget/tree_internal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -697,6 +697,7 @@ func TestTree_Tap(t *testing.T) {

test.Tap(getBranch(t, tree, "A"))
assert.True(t, selected, "Branch should have been selected")
assert.Equal(t, "A", tree.currentFocus)
})
t.Run("BranchIcon", func(t *testing.T) {
data := make(map[string][]string)
Expand Down Expand Up @@ -725,6 +726,7 @@ func TestTree_Tap(t *testing.T) {
}
test.Tap(getLeaf(t, tree, "A"))
assert.True(t, selected, "Leaf should have been selected")
assert.Equal(t, "A", tree.currentFocus)
})
}

Expand Down

0 comments on commit 6fa30e0

Please sign in to comment.