Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
MorningLightMountain713 opened this issue Dec 12, 2024 · 3 comments · Fixed by #5387
Closed

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

MorningLightMountain713 opened this issue Dec 12, 2024 · 3 comments · Fixed by #5387

Comments

@MorningLightMountain713
Copy link

MorningLightMountain713 commented Dec 12, 2024

# 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

Copy link

We found the following entries in the FAQ which you may find helpful:

Feel free to close this issue if you found an answer in the FAQ. Otherwise, please give us a little time to review.

This is an automated reply, generated by FAQtory

@TomJGooding
Copy link
Contributor

This had me scratching my head for a while until I spotted the fix!

I think the other issue you mention with ctrl+c is specific to iTerm as discussed in #5251 (comment) - you might want to raise a separate issue if you're experiencing this with the latest versions.

Copy link

Don't forget to star the repository!

Follow @textualizeio for Textual updates.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants