charmbracelet / charmbracelet/bubbles

Selecting a directory in filepicker model

Open
#659 3 comments 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
Go
Stars
8.9k
Forks
457
Avg merge
1d 18h
Merged PRs (30d)
5

Description

**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.
- OS MacOs Sonoma
- Shell zsh
- Terminal Emulator iterm
- Terminal Multiplexer tmux

**To Reproduce**
Steps to reproduce the behavior:
```go
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

Contributor guide

Open the contributing guide

Research direction

Start at the filepicker component entry point used by filepicker.New and trace how DirAllowed, FileAllowed, and AllowedTypes affect the displayed entries and selection behavior. Reproduce the supplied configuration, then verify that directory-only mode permits directory selection and hides files.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
cli
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.