fluxxcode / egui-file-dialog

Full featured and customizable file dialog for egui
MIT License
86 stars 11 forks source link

Scroll to selection is a bit surprising #126

Closed wiz21b closed 3 months ago

wiz21b commented 5 months ago

On v5.0, if one enters a directory then selects the last visible item in the directory content window, the content windows scrolls to reposition the selection in the middle of the windows.

I don't know if it is done on purpose but it's a bit surprising when what you do is double click on that last visible item. Indeed, if you double click, the first click triggers the scroll of the directory content and consequently, the second click doesn't hit the same file/line as the first one...

I have traced that issue down to these lines:

    fn load_directory_content(&mut self, path: &Path) -> io::Result<()> {
        self.directory_error = None;

        self.directory_content =
            match DirectoryContent::from_path(&self.config, path, self.show_files, &self.config.file_filters) {
                Ok(content) => content,
                Err(err) => {
                    self.directory_content.clear();
                    self.selected_item = None;
                    self.directory_error = Some(err.to_string());
                    return Err(err);
                }
            };

        self.create_directory_dialog.close();
        self.scroll_to_selection = true;  // <--- HERE ! <--- HERE ! <--- HERE ! <--- HERE ! <--- HERE !

Removing that line solves the issue for me, but I admit that I have a very restrained use case of the file dialog (e.g. I don't preselect anything in the list)....

(and thanks for finishing the work on the filters :-) )

fluxxcode commented 5 months ago

Hi, would you be able to record a video of the behavior?

wiz21b commented 5 months ago

vokoscreenNG-2024-06-02_14-54-12.webm

you see the issue when I click on the file "MADEF.dsk". Once I click, it centers MADEF.dsk in the middle of the windows. When you double-click (can't record that, it's too fast), the scrolling starts on the first click and then your second clik (the second half of the double click) ends up on anther file (since things moved under your mouse cursor)...

fluxxcode commented 5 months ago

Interesting, that's not intentional. However, I cannot reproduce this on both the v0.5.0 tag and the develop branch. Is there a repository where I can try to reproduce the error?

fluxxcode commented 4 months ago

I implemented a supposed fix with version v0.6.0. Let me know if the error still occurs.

fluxxcode commented 3 months ago

I'll close the issue for now. If the problem persists, please feel free to reopen it.