Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix clicking on empty part of widget.List not unfocusing #5314

Open
wants to merge 5 commits into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems like an unrelated change? Why are the semantics of RefreshItem changing to that you can't use it to refresh a selected item?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • When the entry is focused, the list item should be unfocused, to unfocus the list item we need this

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But this code is not allowing an item to remain selected when it is refreshed - so scrolling will lose the selected status

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)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the PR says it is unfocusing but this code shows focussing - is this correct?

Copy link
Author

@coder-in-go coder-in-go Dec 19, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the PR says it is unfocusing but this code shows focussing - is this correct?

when the empty portion is clicked the widgets (Entry, list items) are getting unfocused --> the issue

This PR resolves this issue --> The widgets get unfocused when we click the empty portion

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So we should do this by unfocusing surely?
Focusing something else fixes it as a side-effect, not by actually fixing the issue!

}
}

// 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
Loading