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

File Dialog favourites look broken if you use fd.SetLocation for a specific favourite location #2595

Closed
alexballas opened this issue Oct 28, 2021 · 5 comments
Assignees
Labels
blocker Items that would block a forthcoming release bug Something isn't working

Comments

@alexballas
Copy link
Contributor

alexballas commented Oct 28, 2021

Describe the bug:

I have the following code. When I select a file, I also store the last file location so I can then use fd.SetLocation next time to open the same location. If that file location is the "Video" favourite folder (which is the last in the list to the left), when I reopen the dialog, some options are missing from that list. It looks like a graphics glich as the locations will re-appear if I click somewhere.

Video:

(please ignore the video flickering)
https://user-images.githubusercontent.com/11015965/139349869-322903d8-bdb7-4e7b-9c20-e38e666178ac.mp4

Example code:

package main

import (
	"fmt"
	"path/filepath"

	"fyne.io/fyne/v2"
	"fyne.io/fyne/v2/app"
	"fyne.io/fyne/v2/dialog"
	"fyne.io/fyne/v2/storage"
	"fyne.io/fyne/v2/widget"
)

var currentmfolder string

func main() {
	myApp := app.New()
	myWindow := myApp.NewWindow("Test Dialog")

	content := widget.NewButton("Open File Dialog", func() {
		go videoAction(myWindow)
	})
	myWindow.SetContent(content)
	myWindow.Resize(fyne.NewSize(myWindow.Canvas().Size().Width*5, myWindow.Canvas().Size().Height*10))
	myWindow.ShowAndRun()

}

func videoAction(w fyne.Window) {
	fd := dialog.NewFileOpen(func(reader fyne.URIReadCloser, err error) {
		fmt.Println(reader)
		mfile := reader.URI().Path()
		absMediaFile, _ := filepath.Abs(mfile)
		currentmfolder = filepath.Dir(absMediaFile)
	}, w)

	if currentmfolder != "" {
		mfileURI := storage.NewFileURI(currentmfolder)
		mfileLister, _ := storage.ListerForURI(mfileURI)

		fd.SetLocation(mfileLister)
	}

	fd.Show()
}

Device (please complete the following information):

  • OS: Ubuntu 18.04
  • Go version: 1.7.2
  • Fyne version: 2.1.1 (latest)
@alexballas alexballas added the unverified A bug that has been reported but not verified label Oct 28, 2021
@andydotxyz
Copy link
Member

Can anyone replicate this? It's working as expected on my macOS computer? Maybe linux specific somehow...

@alexballas alexballas changed the title File Dialog favourites look broken if you use fd.SetLocation for a specific favourite locations File Dialog favourites look broken if you use fd.SetLocation for a specific favourite location Oct 29, 2021
@alexballas
Copy link
Contributor Author

Test on a seperate linux machine. The issue is still there.
No issues however on Windows

@andydotxyz andydotxyz added the OS:Linux Tickets affecting only Linux label Nov 3, 2021
@alexballas
Copy link
Contributor Author

alexballas commented Nov 27, 2021

Hi @andydotxyz
I run some checks and the issue does not look Linux specific. It seems to relate with the number of items to the favourite list. In linux I get 7 items which seems to cause the issue. On Windows I got 8 items.

To test this theory I run a couple of tests:

  1. I added one more dummy item in the list by hacking the file_unix.go file. With 8 items now, I was unable to replicate the issue. When I added one more (9 now) the issue re-appeared but with a different pattern than the initially reported one. Now only the first item was hidden.
  2. On a windows build which initially was working as expected I added one extra dummy entry in the file_windows.go file
func (f *fileDialog) getPlaces() []favoriteItem {
	var places []favoriteItem

	for _, drive := range listDrives() {
		driveRoot := drive + string(os.PathSeparator) // capture loop var
		driveRootURI, _ := storage.ListerForURI(storage.NewURI("file://" + driveRoot))
		places = append(places, favoriteItem{
			drive,
			theme.StorageIcon(),
			driveRootURI,
		})
	}

	places = append(places, favoriteItem{
		"Dummy item",
		theme.StorageIcon(),
		nil,
	})

	return places
}

After this change I got the same bevahiour as the one in linux. 8 seems to be the magic number here.

@andydotxyz andydotxyz added blocker Items that would block a forthcoming release bug Something isn't working and removed OS:Linux Tickets affecting only Linux unverified A bug that has been reported but not verified labels Nov 28, 2021
@andydotxyz andydotxyz added this to the Fixes (v2.1.x) milestone Nov 28, 2021
@andydotxyz
Copy link
Member

Another note is to say that it does not happen for all SetLocation calls... You need to be 3 items down the list at least as far as I can see...

@andydotxyz
Copy link
Member

Resolved on release/v2.1.x branch

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
blocker Items that would block a forthcoming release bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants