Skip to content

last-of-type (and maybe others) not applied all the time #5386

Closed
@MorningLightMountain713

Description

# Textual Diagnostics

## Versions

| Name    | Value  |
|---------|--------|
| Textual | 1.0.0  |
| Rich    | 13.9.4 |

## Python

| Name           | Value                                                        |
|----------------|--------------------------------------------------------------|
| Version        | 3.12.3                                                       |
| Implementation | CPython                                                      |
| Compiler       | Clang 13.0.0 (clang-1300.0.29.30)                            |
| Executable     | /Users/davew/code/flux/flux_config_frontend/.venv/bin/python |

## Operating System

| Name    | Value                                                                                               |
|---------|-----------------------------------------------------------------------------------------------------|
| System  | Darwin                                                                                              |
| Release | 24.2.0                                                                                              |
| Version | Darwin Kernel Version 24.2.0: Sun Nov  3 20:54:52 PST 2024; root:xnu-11215.60.405~54/RELEASE_X86_64 |

## Terminal

| Name                 | Value              |
|----------------------|--------------------|
| Terminal Application | iTerm.app (3.5.10) |
| TERM                 | xterm-256color     |
| COLORTERM            | truecolor          |
| FORCE_COLOR          | *Not set*          |
| NO_COLOR             | *Not set*          |

## Rich Console options

| Name           | Value                |
|----------------|----------------------|
| size           | width=129, height=38 |
| legacy_windows | False                |
| min_width      | 1                    |
| max_width      | 129                  |
| is_terminal    | True                 |
| encoding       | utf-8                |
| max_height     | 38                   |
| justify        | None                 |
| overflow       | None                 |
| no_wrap        | False                |
| highlight      | None                 |
| markup         | None                 |
| height         | None                 |

Here is an MRE:

from textual.app import App, ComposeResult
from textual.containers import Horizontal
from textual.widgets import Label


class MyApp(App):
    DEFAULT_CSS = """
    Screen {
        &> Horizontal {
            width: 1fr;
            align: center middle;

            &> Label {
                width: 10;
                height: 5;
                }

            &> Label:last-of-type {
                background: red;
            }
        }
    }
    """

    def compose(self) -> ComposeResult:
        with Horizontal():
            yield Label("Start")
            yield Label("Middle")
            yield Label("End")


app = MyApp()
app.run()

When the app loads, it is as expected:

Screenshot 2024-12-12 at 1 40 28 PM

However, when the app loses focus, the styling is no longer applied, and when the app regains focus it is also not applied.

Screenshot 2024-12-12 at 1 41 21 PM

I beieve there is also an issue with hot reload with these styles, as they wern't being applied when I was running with textual --dev until I restarted the app.

On a side note, I'm not sure if this is Iterm doing this but I think it's textual... lately when I ctrl +c some of my key combinations no longer work. I am an avid ctrl + r, ctrl + w, ctrl + a etc etc user.

However, when I ctrl + c textual apps, the ctrl + combos are no longer interpreted until I reset the terminal. See here:

Screenshot 2024-12-12 at 1 38 56 PM

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions