File tree Expand file tree Collapse file tree 1 file changed +30
-0
lines changed Expand file tree Collapse file tree 1 file changed +30
-0
lines changed Original file line number Diff line number Diff line change
1
+ """The standard path of selecting text on focus is well covered by snapshot tests."""
2
+
3
+ from textual import events
4
+ from textual .app import App , ComposeResult
5
+ from textual .widgets import Input
6
+ from textual .widgets .input import Selection
7
+
8
+
9
+ class InputApp (App [None ]):
10
+ """An app with an input widget."""
11
+
12
+ def compose (self ) -> ComposeResult :
13
+ yield Input ("Hello, world!" )
14
+
15
+
16
+ async def test_focus_from_app_focus_does_not_select ():
17
+ """When an Input has focused and the *app* is blurred and then focused (e.g. by pressing
18
+ alt+tab or focusing another terminal pane), then the content of the Input should not be
19
+ fully selected when `Input.select_on_focus=True`.
20
+ """
21
+ async with InputApp ().run_test () as pilot :
22
+ input_widget = pilot .app .query_one (Input )
23
+ input_widget .focus ()
24
+ input_widget .selection = Selection .cursor (0 )
25
+ assert input_widget .selection == Selection .cursor (0 )
26
+ pilot .app .post_message (events .AppBlur ())
27
+ await pilot .pause ()
28
+ pilot .app .post_message (events .AppFocus ())
29
+ await pilot .pause ()
30
+ assert input_widget .selection == Selection .cursor (0 )
You can’t perform that action at this time.
0 commit comments