diff --git a/CHANGELOG.md b/CHANGELOG.md index 041c7ff433..e2c12be03b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,14 +15,17 @@ and this project adheres to [Semantic Versioning](http://semver.org/). - Fixed running `App.run` after `asyncio.run` https://github.com/Textualize/textual/pull/5799 - Fixed triggering a deprecation warning in py >= 3.10 https://github.com/Textualize/textual/pull/5799 - Fixed `Input` invalid cursor position after updating the value https://github.com/Textualize/textual/issues/5811 +- Fixed `DEFAULT_CLASSES` when applied to App https://github.com/Textualize/textual/pull/5827 +- Fixed order of implicit content tag closing https://github.com/Textualize/textual/pull/5823 ### Added - Exposed `CollapsibleTitle` https://github.com/Textualize/textual/pull/5810 +- Added `Color.hsv` property and `Color.from_hsv` class method https://github.com/Textualize/textual/pull/5803 -### Added +### Changed -- Added `Color.hsv` property and `Color.from_hsv` class method https://github.com/Textualize/textual/pull/5803 +- Added a few features to `python -m textual.markup` playgound https://github.com/Textualize/textual/pull/5823 ## [3.2.0] - 2025-05-02 diff --git a/src/textual/app.py b/src/textual/app.py index ba87005aba..478593124e 100644 --- a/src/textual/app.py +++ b/src/textual/app.py @@ -565,7 +565,7 @@ def __init__( CssPathError: When the supplied CSS path(s) are an unexpected type. """ self._start_time = perf_counter() - super().__init__() + super().__init__(classes=self.DEFAULT_CLASSES) self.features: frozenset[FeatureFlag] = parse_features(os.getenv("TEXTUAL", "")) self._registered_themes: dict[str, Theme] = {} diff --git a/tests/snapshot_tests/__snapshots__/test_snapshots/test_app_default_classes.svg b/tests/snapshot_tests/__snapshots__/test_snapshots/test_app_default_classes.svg new file mode 100644 index 0000000000..de230ce858 --- /dev/null +++ b/tests/snapshot_tests/__snapshots__/test_snapshots/test_app_default_classes.svg @@ -0,0 +1,151 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + DC + + + + + + + + + + ┌──────────────────────────────────────────────────────────────────────────────┐ + + + + + + + + + + + + + + + + + + + + + + +└──────────────────────────────────────────────────────────────────────────────┘ + + + diff --git a/tests/snapshot_tests/test_snapshots.py b/tests/snapshot_tests/test_snapshots.py index 7f95c17f89..5b9db68929 100644 --- a/tests/snapshot_tests/test_snapshots.py +++ b/tests/snapshot_tests/test_snapshots.py @@ -2554,6 +2554,7 @@ def on_mount(self) -> None: assert snap_compare(PSApp()) + def test_child_pseudo_classes(snap_compare): """Test pseudo classes added in https://github.com/Textualize/textual/pull/XXXX @@ -4105,6 +4106,7 @@ def compose(self) -> ComposeResult: assert snap_compare(BreakpointApp(), terminal_size=size) + @pytest.mark.parametrize( "size", [ @@ -4155,6 +4157,7 @@ def compose(self) -> ComposeResult: assert snap_compare(BreakpointApp(), terminal_size=size) + def test_compact(snap_compare): """Test compact styles. @@ -4186,3 +4189,29 @@ def compose(self) -> ComposeResult: yield TextArea("Edit me", compact=True) assert snap_compare(CompactApp()) + + +def test_app_default_classes(snap_compare): + """Test that default classes classvar is working. + + You should see a blue screen with a white border, confirming that + the classes foo and bar have been added to the app. + + """ + from textual.app import App + + class DC(App): + DEFAULT_CLASSES = "foo bar" + + CSS = """ + DC { + &.foo { + Screen { background: blue; } + } + &.bar { + Screen { border: white; } + } + } + """ + + assert snap_compare(DC())