@@ -10,8 +10,11 @@ class Focusable(Widget, can_focus=True):
1010class NonFocusable (Widget , can_focus = False , can_focus_children = False ):
1111 pass
1212
13+ class ChildrenFocusableOnly (Widget , can_focus = False , can_focus_children = True ):
14+ pass
15+
1316
14- async def test_focus_chain ():
17+ def test_focus_chain ():
1518 app = App ()
1619 app ._set_active ()
1720 app .push_screen (Screen ())
@@ -27,13 +30,14 @@ async def test_focus_chain():
2730 Focusable (Focusable (id = "Paul" ), id = "container1" ),
2831 NonFocusable (Focusable (id = "Jessica" ), id = "container2" ),
2932 Focusable (id = "baz" ),
33+ ChildrenFocusableOnly (Focusable (id = "child" )),
3034 )
3135
32- focused = [widget .id for widget in screen .focus_chain ]
33- assert focused == ["foo" , "Paul" , "baz" ]
36+ focus_chain = [widget .id for widget in screen .focus_chain ]
37+ assert focus_chain == ["foo" , "container1" , " Paul" , "baz" , "child " ]
3438
3539
36- async def test_focus_next_and_previous ():
40+ def test_focus_next_and_previous ():
3741 app = App ()
3842 app ._set_active ()
3943 app .push_screen (Screen ())
@@ -46,11 +50,16 @@ async def test_focus_next_and_previous():
4650 Focusable (Focusable (id = "Paul" ), id = "container1" ),
4751 NonFocusable (Focusable (id = "Jessica" ), id = "container2" ),
4852 Focusable (id = "baz" ),
53+ ChildrenFocusableOnly (Focusable (id = "child" )),
4954 )
5055
5156 assert screen .focus_next ().id == "foo"
57+ assert screen .focus_next ().id == "container1"
5258 assert screen .focus_next ().id == "Paul"
5359 assert screen .focus_next ().id == "baz"
60+ assert screen .focus_next ().id == "child"
5461
62+ assert screen .focus_previous ().id == "baz"
5563 assert screen .focus_previous ().id == "Paul"
64+ assert screen .focus_previous ().id == "container1"
5665 assert screen .focus_previous ().id == "foo"
0 commit comments