Skip to content

Commit 14c43ef

Browse files
committed
fixed focus-within
1 parent 3992a38 commit 14c43ef

File tree

4 files changed

+13
-6
lines changed

4 files changed

+13
-6
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](http://keepachangelog.com/)
66
and this project adheres to [Semantic Versioning](http://semver.org/).
77

8+
## Unreleased
9+
10+
- Fixed broken focus-within https://github.com/Textualize/textual/issues/5184
11+
812
## [0.85.1] - 2024-10-26
913

1014
### Fixed

src/textual/app.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -762,8 +762,8 @@ def __init__(
762762
perform work after the app has resumed.
763763
"""
764764

765-
self.set_class(self.dark, "-dark-mode")
766-
self.set_class(not self.dark, "-light-mode")
765+
self.set_class(self.dark, "-dark-mode", update=False)
766+
self.set_class(not self.dark, "-light-mode", update=False)
767767

768768
self.animation_level: AnimationLevel = constants.TEXTUAL_ANIMATIONS
769769
"""Determines what type of animations the app will display.

src/textual/css/stylesheet.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -433,13 +433,14 @@ def _check_rule(
433433
if _check_selectors(selector_set.selectors, css_path_nodes):
434434
yield selector_set.specificity
435435

436-
# pseudo classes which iterate over many nodes
437-
# these have the potential to be slow, and shouldn't be used in a cache key
438-
EXPENSIVE_PSEUDO_CLASSES = {
436+
# pseudo classes which iterate over multiple nodes
437+
# These shouldn't be used in a cache key
438+
EXCLUDE_PSEUDO_CLASSES = {
439439
"first-of-type",
440440
"last-of_type",
441441
"odd",
442442
"even",
443+
"focus-within",
443444
}
444445

445446
def apply(
@@ -487,7 +488,7 @@ def apply(
487488
cache_key: tuple | None = None
488489

489490
if cache is not None and all_pseudo_classes.isdisjoint(
490-
self.EXPENSIVE_PSEUDO_CLASSES
491+
self.EXCLUDE_PSEUDO_CLASSES
491492
):
492493
cache_key = (
493494
node._parent,

src/textual/widgets/_button.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,8 @@ def __init__(
210210

211211
self.label = label
212212
self.variant = variant
213+
self.set_reactive(Button.variant, variant)
214+
self.add_class(f"-{variant}", update=False)
213215
self.action = action
214216
self.active_effect_duration = 0.2
215217
"""Amount of time in seconds the button 'press' animation lasts."""

0 commit comments

Comments
 (0)