charmbracelet / bubbles

TUI components for Bubble Tea 🫧
MIT License
5.64k stars 263 forks source link

Selecting a directory in filepicker model #659

Open igloo1505 opened 2 weeks ago

igloo1505 commented 2 weeks ago

Describe the bug I'm not sure if this is possible with the existing model, but there doesn't appear to be any documentation on how to pick directories on the filepicker component. The component looks phenomenonal, but even setting the DirAllowed to true and the FileAllowed to false, files are still shown and directories can't be selected, at least in any obvious way. The component looks phenomenal, but I'm unsure of how to use the component to select only directories.

Setup Please complete the following information along with version numbers, if applicable.

To Reproduce Steps to reproduce the behavior:

func InitialFilePicker() *model {
    fp := filepicker.New()
    fp.DirAllowed = true
    fp.FileAllowed = false
    fp.AllowedTypes = []string{}
    fp.AutoHeight = true
    fp.CurrentDirectory, _ = os.UserHomeDir()
    m := model{
        filepicker: fp,
        err: nil,
    }
    return &m
}

Source Code See Above

Expected behavior To be able to select directories, and to hide files in the options list.

Additional context I'm very new to Go, but don't feel that this is a code issue, as the app in it's current state is super simple

meowgorithm commented 2 weeks ago

Listen, buddy, it's called FilePicker, not DirPicker. Kidding—this is actually really acute. We'll need to think about how this would work UX-wise but it's totally something you should be able to do with the file picker.

igloo1505 commented 2 weeks ago

Listen, buddy, it's called FilePicker, not DirPicker. Kidding—this is actually really acute. We'll need to think about how this would work UX-wise but it's totally something you should be able to do with the file picker.

I know... I was without a connection all night otherwise I would've taken this down, but like an hour after I posted it I was walking around and thought "Dude... you can definitely figure this out without posting an issue". I've been working with Go for like 3 days, and pretty much all of that while working offline without the ability to look at the docs, so I'm still in that mode of getting kind of flustered with the syntax or the type system and letting that balloon out of control. Feel free to close this, and I'll post a reply with whatever solution I find when I handle that tomorrow.