Skip to content

Commit 5858acb

Browse files
committed
fix for setting the theme early
1 parent ccfcc7f commit 5858acb

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

src/textual/app.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1419,7 +1419,7 @@ def _validate_theme(self, theme_name: str) -> str:
14191419
raise InvalidThemeError(message)
14201420
return theme_name
14211421

1422-
def _watch_theme(self, theme_name: str) -> None:
1422+
async def _watch_theme(self, theme_name: str) -> None:
14231423
"""Apply a theme to the application.
14241424
14251425
This method is called when the theme reactive attribute is set.

tests/snapshot_tests/test_snapshots.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4654,3 +4654,25 @@ def compose(self) -> ComposeResult:
46544654
yield TextArea(placeholder=TEXT)
46554655

46564656
assert snap_compare(PlaceholderApp())
4657+
4658+
4659+
def test_rich_log_early_write(snap_compare) -> None:
4660+
"""Regression test for https://github.com/Textualize/textual/issues/6123
4661+
4662+
You should see a RichLog with "Hello World" text
4663+
4664+
"""
4665+
4666+
class TestApp(App):
4667+
def compose(self) -> ComposeResult:
4668+
with Horizontal():
4669+
yield RichLog()
4670+
4671+
def on_mount(self) -> None:
4672+
self.theme = "nord"
4673+
4674+
def on_ready(self) -> None:
4675+
log_widget = self.query_one(RichLog)
4676+
log_widget.write("Hello, World!")
4677+
4678+
assert snap_compare(TestApp())

0 commit comments

Comments
 (0)