Skip to content

Commit b00c159

Browse files
authored
Merge pull request #6141 from Textualize/fix-rich-log-write
fix for setting the theme early
2 parents 4e09a26 + 43970ae commit b00c159

File tree

4 files changed

+176
-2
lines changed

4 files changed

+176
-2
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
3232
- Fixed issue where Segments with a style of `None` aren't rendered https://github.com/Textualize/textual/pull/6109
3333
- Fixed visual glitches and crash when changing `DataTable.header_height` https://github.com/Textualize/textual/pull/6128
3434
- Fixed TextArea.placeholder not handling multi-lines https://github.com/Textualize/textual/pull/6138
35+
- Fixed issue with RichLog when App.theme is set early https://github.com/Textualize/textual/pull/6141
3536

3637
## [6.1.0] - 2025-08-01
3738

src/textual/app.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3657,8 +3657,9 @@ def refresh_css(self, animate: bool = True) -> None:
36573657
stylesheet.reparse()
36583658
stylesheet.update(self.app, animate=animate)
36593659
try:
3660-
self.screen._refresh_layout(self.size)
3661-
self.screen._css_update_count = self._css_update_count
3660+
if self.screen.is_mounted:
3661+
self.screen._refresh_layout(self.size)
3662+
self.screen._css_update_count = self._css_update_count
36623663
except ScreenError:
36633664
pass
36643665
# The other screens in the stack will need to know about some style
Lines changed: 150 additions & 0 deletions
Loading

tests/snapshot_tests/test_snapshots.py

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

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

0 commit comments

Comments
 (0)