diff --git a/CHANGELOG.md b/CHANGELOG.md index 67652d343d..90df2e9dd6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/). +## [Unreleased] + +### Fixed + +- Fixed a crash when applying `pointer` styles while changing theme before the screen stack is ready https://github.com/Textualize/textual/issues/6360 + ## [8.2.8] - 2026-06-30 ### Fixed diff --git a/src/textual/css/_style_properties.py b/src/textual/css/_style_properties.py index 85b7b4be80..9168457f98 100644 --- a/src/textual/css/_style_properties.py +++ b/src/textual/css/_style_properties.py @@ -877,11 +877,12 @@ def __set__(self, obj: StylesBase, value: EnumType | None = None): parent=self._refresh_parent, ) if self._pointer and obj.node is not None: + from textual.app import ScreenStackError from textual.dom import NoScreen try: obj.node.screen.update_pointer_shape() - except NoScreen: + except (NoScreen, ScreenStackError): pass diff --git a/tests/test_app.py b/tests/test_app.py index e95b930708..7f36d99fa4 100644 --- a/tests/test_app.py +++ b/tests/test_app.py @@ -405,6 +405,25 @@ def compose(self) -> ComposeResult: assert app.screen._pointer_shape == "pointer" +async def test_app_pointer_style_with_theme_before_screen_stack() -> None: + """Regression test for https://github.com/Textualize/textual/issues/6360.""" + + class PointerThemeApp(App[None]): + CSS = """ + * { + pointer: default; + } + """ + + def __init__(self) -> None: + super().__init__() + self.theme = "textual-light" + + app = PointerThemeApp() + async with app.run_test(): + assert app.theme == "textual-light" + + async def test_get_screen_stack() -> None: """Test get_screen_stack"""