Skip to content

Style changes made on_mount no longer applying correctly in 0.45 #3858

@davep

Description

@davep

Given this code:

from textual import __version__
from textual.app import App, ComposeResult
from textual.widgets import Static

class BrokenClassesApp(App[None]):

    CSS = """
    Screen {
        align: center middle;
    }

    Static {
        width: 50%;
        height: 50%;
        border: solid;
    }

    Screen.go-red Static {
        background: red;
    }
    """

    def compose(self) -> ComposeResult:
        yield Static(f"This should have a red background\n\nTextual {__version__}")

    def on_mount(self) -> None:
        self.screen.set_class(True, "go-red")

if __name__ == "__main__":
    BrokenClassesApp().run()

in Textual 0.44.x the result was as I'd expect:

Screenshot 2023-12-12 at 17 56 58

but as of 0.45 it seems the class no longer applies:

Screenshot 2023-12-12 at 17 57 09

Flagging @willmcgugan for triage as this seems like an unintended consequence of some of the CSS performance tweaks.

Metadata

Metadata

Assignees

No one assigned

    Labels

    TaskbugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions