mirror of
https://github.com/rivo/tview.git
synced 2026-04-26 21:35:54 +03:00
[GH-ISSUE #115] Dropdowns -- selected func called twice #90
Labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/tview#90
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @hoop33 on GitHub (May 11, 2018).
Original GitHub issue: https://github.com/rivo/tview/issues/115
When you select an item in the dropdown, the
selectedfunc runs twice. First, the wrappedlistruns it:https://github.com/rivo/tview/blob/master/list.go#L301
And then the
dropdownhandler runs it:https://github.com/rivo/tview/blob/master/dropdown.go#L365
I would guess that deferring to the list's call would be fine, and that the dropdown's "Trigger selected event" block could be removed. I can submit a PR.
Thanks for this library!
@hoop33 commented on GitHub (May 11, 2018):
Actually, removing the call from
dropdownwould cause an issue if theselectedfunc changes focus -- the call fromlistwould change the focus, and thendropdownchanges it back ( https://github.com/rivo/tview/blob/master/dropdown.go#L360 ), so it looks like the fix isn't simply to remove that call.@rivo commented on GitHub (May 12, 2018):
Thank you for spotting this. I actually removed the per-item
Listcallback to resolve this. I couldn't find any issue with this solution but if this doesn't work for you, let me know.@hoop33 commented on GitHub (May 14, 2018):
Ah -- much cleaner solution. Thanks!