Describe the bug
I am working on a tui with multiple nested models and I wanted to use a filepicker to select files from the fs. I was very happy that bubbles already got such object, but the problem is, that is does not work as expected.
When I call into my nested model that contains the filepicker, the filepicker does not show up, although I can navigate within it (I know this due to tracking the current path, which changes while using the arrow keys).
The thing, what makes me suspicious and let me think that this behavior is a bug is, that when I call into that nested model from the beginning of the tea program (so the nested Model is the initial Model), than the filepicker works perfectly fine and everything is displayed properly.
Setup
Please complete the following information along with version numbers, if applicable.
OS [Ubuntu]
Shell [zsh]
To Reproduce
Steps to reproduce the behavior:
Start tui and navigate into the nested model and than focus the filepicker. It won't work.
Change code, so that the nested model is the initial model, focus the filepicker. I will work.
Source Code
This is the code for my program start:
If the Filepicker is called from another model and is not used as the initial model that the heigth of the filepicker is 0. Setting the heigth fixed it.
Describe the bug I am working on a tui with multiple nested models and I wanted to use a filepicker to select files from the fs. I was very happy that bubbles already got such object, but the problem is, that is does not work as expected. When I call into my nested model that contains the filepicker, the filepicker does not show up, although I can navigate within it (I know this due to tracking the current path, which changes while using the arrow keys). The thing, what makes me suspicious and let me think that this behavior is a bug is, that when I call into that nested model from the beginning of the tea program (so the nested Model is the initial Model), than the filepicker works perfectly fine and everything is displayed properly.
Setup Please complete the following information along with version numbers, if applicable.
To Reproduce Steps to reproduce the behavior:
Source Code This is the code for my program start:
type TUICmd struct{}
func (cmd *TUICmd) Run() error { if _, err := tea.NewProgram( tui.MasterModel{ CurrentModel: tui.NewStartModel(constants.StartListLogin), }, tea.WithAltScreen(), tea.WithMouseCellMotion()).Run(); err != nil { return err } return nil }
This is the code, where I manage the models:
type MasterModel struct { CurrentModel tea.Model }
func (m MasterModel) Init() tea.Cmd { return m.CurrentModel.Init() }
func (m MasterModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) { var cmd tea.Cmd
}
func (m MasterModel) View() string { return m.CurrentModel.View() }
And this is the code that uses the filepicker:
type AddModel struct { inputs []textinput.Model filePicker filepicker.Model selectedFile string cursor int originalIndex int err error } func NewAddTestModel(originalIndex int) *AddModel { inputs := make([]textinput.Model, addItems)
}
func (am AddModel) Init() tea.Cmd { return am.filePicker.Init() }
func (am AddModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) { var cmd tea.Cmd
}
func (am AddModel) View() string { var ( output string errorMsg string )
}
Expected behavior The expected behavior is that the filepicker should also work if it is used in a nested model.