Fix :focus-within pseudo-selector (#885)

* Fix :focus-within pseudo-selector

* Remove debug prints
This commit is contained in:
darrenburns
2022-10-13 10:42:46 +01:00
committed by GitHub
parent 43e5ac7d0f
commit a16db13157
2 changed files with 7 additions and 15 deletions

View File

@@ -424,7 +424,6 @@ class Stylesheet:
# Calculate replacement rules (defaults + new rules)
new_styles = Styles(node, rules)
if new_styles == base_styles:
# Nothing to change, return early
return

View File

@@ -52,7 +52,6 @@ if TYPE_CHECKING:
ScrollUp,
)
_JUSTIFY_MAP: dict[str, JustifyMethod] = {
"start": "left",
"end": "right",
@@ -1889,22 +1888,16 @@ class Widget(DOMNode):
self.refresh()
def _on_descendant_focus(self, event: events.DescendantFocus) -> None:
self.descendant_has_focus = True
if "focus-within" in self.pseudo_classes:
sender = event.sender
for child in self.walk_children(False):
child.refresh()
if child is sender:
break
if not self.descendant_has_focus:
self.descendant_has_focus = True
def _on_descendant_blur(self, event: events.DescendantBlur) -> None:
self.descendant_has_focus = False
if self.descendant_has_focus:
self.descendant_has_focus = False
def watch_descendant_has_focus(self, value: bool) -> None:
if "focus-within" in self.pseudo_classes:
sender = event.sender
for child in self.walk_children(False):
child.refresh()
if child is sender:
break
self.app._require_stylesheet_update.add(self)
def _on_mouse_scroll_down(self, event) -> None:
if self.allow_vertical_scroll: