[GH-ISSUE #1026] DropDown disappears when it's inside a form and we don't select anything #742

Closed
opened 2026-03-04 01:07:26 +03:00 by kerem · 2 comments
Owner

Originally created by @manuecg on GitHub (Sep 18, 2024).
Original GitHub issue: https://github.com/rivo/tview/issues/1026

If we have a DropDown inside a form, which has the values form.SetFieldTextColor(tcell.ColorBlack) and form.SetFieldBackgroundColor(tcell.ColorWhite), when we click on it and exit without selecting an option, it takes the 'FieldTextColor' value and causes a hiding effect. I believe the effect can be better appreciated with the video.

https://github.com/user-attachments/assets/e3d3d7d3-5aae-449e-9e5e-22202f8c8ea7

`

   app := tview.NewApplication()
dropdown := tview.NewDropDown().
	SetLabel("Select an option (hit Enter): ").
	SetOptions([]string{"First", "Second", "Third", "Fourth", "Fifth"}, func(text string, index int) {
	
})
dropdown.SetLabel("DropDown: ")
inputF:=tview.NewInputField()
inputF.SetLabel("InputField")

form:=tview.NewForm()
form.AddFormItem(inputF)
form.AddFormItem(dropdown)

form.SetFieldTextColor(tcell.ColorBlack)
form.SetFieldBackgroundColor(tcell.ColorWhite)

app.EnableMouse(true)
if err := app.SetRoot(form, true).SetFocus(form).Run(); err != nil {
	panic(err)
}

`

@rivo Do you think this could be a possible bug? Or am I doing something wrong?

Originally created by @manuecg on GitHub (Sep 18, 2024). Original GitHub issue: https://github.com/rivo/tview/issues/1026 If we have a DropDown inside a form, which has the values form.SetFieldTextColor(tcell.ColorBlack) and form.SetFieldBackgroundColor(tcell.ColorWhite), when we click on it and exit without selecting an option, it takes the 'FieldTextColor' value and causes a hiding effect. I believe the effect can be better appreciated with the video. https://github.com/user-attachments/assets/e3d3d7d3-5aae-449e-9e5e-22202f8c8ea7 ` app := tview.NewApplication() dropdown := tview.NewDropDown(). SetLabel("Select an option (hit Enter): "). SetOptions([]string{"First", "Second", "Third", "Fourth", "Fifth"}, func(text string, index int) { }) dropdown.SetLabel("DropDown: ") inputF:=tview.NewInputField() inputF.SetLabel("InputField") form:=tview.NewForm() form.AddFormItem(inputF) form.AddFormItem(dropdown) form.SetFieldTextColor(tcell.ColorBlack) form.SetFieldBackgroundColor(tcell.ColorWhite) app.EnableMouse(true) if err := app.SetRoot(form, true).SetFocus(form).Run(); err != nil { panic(err) } ` @rivo Do you think this could be a possible bug? Or am I doing something wrong?
kerem closed this issue 2026-03-04 01:07:26 +03:00
Author
Owner

@rivo commented on GitHub (Sep 21, 2024):

The latest commit solves your issue. However, this DropDown stuff is very old code and requires some refactoring. So things might still change slightly.

<!-- gh-comment-id:2365168456 --> @rivo commented on GitHub (Sep 21, 2024): The latest commit solves your issue. However, this `DropDown` stuff is very old code and requires some refactoring. So things might still change slightly.
Author
Owner

@manuelacgu commented on GitHub (Sep 23, 2024):

Hi, Thank you very much, I have tested the new version and everything works fine.

<!-- gh-comment-id:2367354764 --> @manuelacgu commented on GitHub (Sep 23, 2024): Hi, Thank you very much, I have tested the new version and everything works fine.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/tview#742
No description provided.