Skip to content

Commit

Permalink
Fix for clicking on empty part of widget.List not unfocusing
Browse files Browse the repository at this point in the history
  • Loading branch information
coder-in-go committed Dec 18, 2024
1 parent 8f27762 commit 3b9c451
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions widget/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ func (l *List) RefreshItem(id ListItemID) {
return
}
l.BaseWidget.Refresh()
l.Unselect(id)
lo := l.scroller.Content.(*fyne.Container).Layout.(*listLayout)
lo.renderLock.RLock() // ensures we are not changing visible info in render code during the search
item, ok := lo.searchVisible(lo.visible, id)
Expand Down Expand Up @@ -386,6 +387,17 @@ func (l *List) contentMinSize() fyne.Size {
return fyne.NewSize(l.itemMin.Width, height+separatorThickness*float32(items-1))
}

func (l *List) Tapped(event *fyne.PointEvent) {
canvas := fyne.CurrentApp().Driver().CanvasForObject(l)
if canvas != nil {
// First, unfocus the currently focused widget if any
if l.focused {
l.FocusLost()
}
canvas.Focus(l)
}
}

// fills l.visibleRowHeights and also returns offY and minRow
func (l *listLayout) calculateVisibleRowHeights(itemHeight float32, length int, th fyne.Theme) (offY float32, minRow int) {
rowOffset := float32(0)
Expand Down

0 comments on commit 3b9c451

Please sign in to comment.