Skip to content

Commit 81e4e12

Browse files
authored
fix: focus correctly when loading help screen (#141)
Signed-off-by: Henry Schreiner <[email protected]>
1 parent 963abe9 commit 81e4e12

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

src/uproot_browser/tui/help.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ def compose(self) -> textual.app.ComposeResult:
3939
yield textual.widgets.Button("Done", variant="primary", id="help-done")
4040

4141
def on_mount(self) -> None:
42-
self.query_one(textual.widgets.Markdown).focus()
42+
self.query_one("#help-text", textual.widgets.MarkdownViewer).focus()
4343

4444
def on_button_pressed(self, _event: textual.widgets.Button.Pressed) -> None:
4545
self.app.pop_screen()

tests/test_tui.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,13 @@ async def test_browse_empty_vim() -> None:
3434
).run_test() as pilot:
3535
await pilot.press("j", "l", "j", "enter")
3636
assert pilot.app.query_one("#main-view").current == "empty"
37+
38+
39+
async def test_help_focus() -> None:
40+
async with Browser(
41+
Path(skhep_testdata.data_path("uproot-empty.root"))
42+
).run_test() as pilot:
43+
await pilot.press("?")
44+
focus_chain = [widget.id for widget in pilot.app.screen.focus_chain]
45+
assert focus_chain == ["help-text", None, "help-done"]
46+
assert pilot.app.screen.focused.id == "help-text"

0 commit comments

Comments
 (0)