Coverage for src / lilbee / cli / tui / widgets / nav_aware_input.py: 100%
8 statements
« prev ^ index » next coverage.py v7.13.4, created at 2026-04-29 19:16 +0000
« prev ^ index » next coverage.py v7.13.4, created at 2026-04-29 19:16 +0000
1"""Input subclass that lets screen-nav keys ([ and ]) bubble up.
3Textual's default `Input.check_consume_key` returns True for every printable
4character, which tells the binding dispatcher to skip any ancestor binding for
5those keys even if that binding is marked `priority=True`. That means the
6app-level screen navigation keys declared as `[` / `]` silently get typed into
7the focused input instead of switching screens.
9This subclass exempts `left_square_bracket` and `right_square_bracket` from the
10consume check so those keys bubble up to the screen/app bindings unchanged.
11All other printable characters are still captured normally, preserving the
12full Input behavior for regular text entry.
13"""
15from __future__ import annotations
17from textual.widgets import Input
19_BUBBLE_KEYS: frozenset[str] = frozenset({"left_square_bracket", "right_square_bracket"})
22class NavAwareInput(Input):
23 """Input that does not consume the `[` / `]` screen-nav keys."""
25 def check_consume_key(self, key: str, character: str | None) -> bool:
26 if key in _BUBBLE_KEYS:
27 return False
28 return super().check_consume_key(key, character)