Skip to content

Commit

Permalink
Docstrings
Browse files Browse the repository at this point in the history
  • Loading branch information
darrenburns committed Dec 18, 2024
1 parent 9695d04 commit 4ba155b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
1 change: 0 additions & 1 deletion docs/widgets/select.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,6 @@ The `Select` widget has a `type_to_search` attribute which allows you to type to

## Reactive Attributes


| Name | Type | Default | Description |
|------------|--------------------------------|------------------------------------------------|-------------------------------------|
| `expanded` | `bool` | `False` | True to expand the options overlay. |
Expand Down
10 changes: 9 additions & 1 deletion src/textual/widgets/_select.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,21 @@ class UpdateSelection(Message):
def __init__(self, type_to_search: bool = True) -> None:
super().__init__()
self._type_to_search = type_to_search
"""If True (default), the user can type to search for a matching option and the cursor will jump to it."""

self._search_query: str = ""
"""The current search query used to find a matching option and jump to it."""

self._search_reset_delay: float = 0.7
"""The number of seconds to wait after the most recent key press before resetting the search query."""

def on_mount(self) -> None:
def reset_query() -> None:
self._search_query = ""

self._search_reset_timer = Timer(self, 0.7, callback=reset_query)
self._search_reset_timer = Timer(
self, self._search_reset_delay, callback=reset_query
)

def watch_has_focus(self, value: bool) -> None:
self._search_query = ""
Expand Down

0 comments on commit 4ba155b

Please sign in to comment.