Closed
Description
Have you checked closed issues? https://github.com/Textualize/textual/issues?q=is%3Aissue+is%3Aclosed
Yes.
Have you checked against the most recent version of Textual? https://pypi.org/search/?q=textual
Yes.
Issue
Please give a brief but clear explanation of the issue. If you can, include a complete working example that demonstrates the bug. Check it can run without modifications.
After focus
ing on a Select, I cannot programmatically return focus to a ListView and/or ListItem.
from textual.app import App, ComposeResult
from textual.containers import HorizontalGroup, Container
from textual.widgets import ListView, ListItem, Label, Select
opts = [ "foo", "bar", "zoo" ]
class MyListItem(ListItem):
def __init__(self, opts: list[str]) -> None:
self.opts = opts
self.lab = Label("Hello!")
self.sel = Select(options=[ (opt, opt) for opt in self.opts ])
super().__init__()
def compose(self):
with HorizontalGroup():
yield self.lab
yield self.sel
def on_select_changed(self, event: Select.Changed):
self.app.query_one(MyListView).focus()
# self.focus()
class MyListView(ListView):
def compose(self):
yield MyListItem(opts)
yield MyListItem(opts)
yield MyListItem(opts)
def on_list_view_selected(self, event: ListView.Selected):
event.item.sel.focus()
event.item.sel.expanded = True
class TUI(App):
def compose(self):
with Container():
yield MyListView()
TUI().run()
What happens:
- Hit enter
- Focus transfers to Select
- Update the Item
- Focus is not returned to the ListView or ListItem
- Hitting up/down opens the Select rather than navigating the ListView
Expected:
- Focus is returned to the ListView or ListItem.
- Hitting up/down iterates over the ListItems
Metadata
Metadata
Assignees
Labels
No labels