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

[Regression] calling Hide() on a widget.PopUp does not call FocusLost() on focused widgets contained in it #4374

Open
2 tasks done
dweymouth opened this issue Nov 6, 2023 · 4 comments
Labels
bug Something isn't working

Comments

@dweymouth
Copy link
Contributor

dweymouth commented Nov 6, 2023

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

This applies to both modal and non-modal popups but only affects non-modal popups when they are programmatically hidden. (ie when hidden by a user tap elsewhere it has the correct behavior)

Note also that the widget IS actually unfocused. If you show the popup again the widget does not have focus, but its styling will still suggest that it does!

How to reproduce

Run the example code, show the popup, then hide it without focusing the entry. Show it again, and all is good. Now, focus the entry and hide the popup, and re-show it. The entry will appear focused without actually being focused. This is because its FocusLost isn't called when hiding the popup.

Screenshots

No response

Example code

package main

import (
	"log"

	"fyne.io/fyne/v2"
	"fyne.io/fyne/v2/app"
	"fyne.io/fyne/v2/container"
	"fyne.io/fyne/v2/widget"
)

type focusLostEntry struct {
	widget.Entry
}

func newFocusLostEntry() *focusLostEntry {
	e := &focusLostEntry{}
	e.ExtendBaseWidget(e)
	return e
}

func (e *focusLostEntry) FocusLost() {
	log.Println("Focus lost")
	e.Entry.FocusLost()
}

func main() {
	app := app.New()
	win := app.NewWindow("Popup FocusLost bug")

	var pop *widget.PopUp
	hide := widget.NewButton("Hide", func() {
		pop.Hide()
	})
	e := newFocusLostEntry()
	e.PlaceHolder = "Focus me"
	pop = widget.NewModalPopUp(container.NewVBox(
		widget.NewLabel("This is a modal popup"),
		e,
		hide,
	), win.Canvas())

	win.SetContent(container.NewBorder(
		widget.NewLabel("This is the main window content"), nil, nil, nil,
		container.NewCenter(widget.NewButton("Show", func() {
			pop.Show()
		})),
	))
	win.Resize(fyne.NewSize(400, 300))
	win.ShowAndRun()
}

Fyne version

2.4.1

Go compiler version

go1.21.1

Operating system and version

macOS Ventura M2

Additional Information

No response

@dweymouth
Copy link
Contributor Author

dweymouth commented Nov 6, 2023

On further investigation this appears to be a regression from 2.3.5 -> 2.4.0

@dweymouth dweymouth added the blocker Items that would block a forthcoming release label Nov 6, 2023
@dweymouth dweymouth added this to the D fixes (v2.4.x) milestone Nov 6, 2023
@dweymouth dweymouth changed the title calling Hide() on a widget.PopUp does not call FocusLost() on focused widgets contained in it [Regression] calling Hide() on a widget.PopUp does not call FocusLost() on focused widgets contained in it Nov 6, 2023
dweymouth added a commit to dweymouth/fyne that referenced this issue Nov 6, 2023
dweymouth added a commit to dweymouth/fyne that referenced this issue Nov 23, 2023
dweymouth added a commit to dweymouth/fyne that referenced this issue Jan 12, 2024
dweymouth added a commit to dweymouth/fyne that referenced this issue Feb 14, 2024
dweymouth added a commit to dweymouth/fyne that referenced this issue May 24, 2024
dweymouth added a commit to dweymouth/fyne that referenced this issue May 28, 2024
dweymouth added a commit to dweymouth/fyne that referenced this issue May 31, 2024
dweymouth added a commit to dweymouth/fyne that referenced this issue Jul 1, 2024
@andydotxyz
Copy link
Member

Is this truly a blocker for v2.5.0, or is that tag just carried over from 2.4.x but it was not fixed when it should have been?

@dweymouth
Copy link
Contributor Author

I think it was just carried over. Would be nice to get a fix but I certainly don't think it's a blocker, it can be addressed in a bug fix release

@dweymouth dweymouth removed the blocker Items that would block a forthcoming release label Jul 7, 2024
@andydotxyz
Copy link
Member

Thanks

dweymouth added a commit to dweymouth/fyne that referenced this issue Jul 21, 2024
dweymouth added a commit to dweymouth/fyne that referenced this issue Jul 21, 2024
dweymouth added a commit to dweymouth/fyne that referenced this issue Jul 24, 2024
dweymouth added a commit to dweymouth/fyne that referenced this issue Aug 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants