-
-
Notifications
You must be signed in to change notification settings - Fork 1k
Open
Description
I've been hesitant to create an issue for this, but should widgets automatically scroll to the highlighted item after being resized? Or is this something that is expected to be handled by the developer?
The below example with an OptionList hopefully demonstrates what I mean. Obviously resizing the terminal could also cause the highlighted item to go out of view.
from textual.app import App, ComposeResult
from textual.containers import Horizontal
from textual.widgets import Footer, OptionList, Placeholder
class ExampleApp(App):
BINDINGS = [
("t", "toggle_panel", "Toggle Panel"),
]
CSS = """
Placeholder {
width: 2fr;
display: none;
}
.show-panel {
Placeholder {
display: block;
}
}
"""
def compose(self) -> ComposeResult:
with Horizontal():
yield OptionList(
*[
f"This is option {i} which is long and might wrap when the widget is resized"
for i in range(100)
]
)
yield Placeholder()
yield Footer()
def on_mount(self) -> None:
options = self.query_one(OptionList)
options.highlighted = 50
def action_toggle_panel(self) -> None:
self.toggle_class("show-panel")
if __name__ == "__main__":
app = ExampleApp()
app.run()Metadata
Metadata
Assignees
Labels
No labels