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

Unexpected margin-right when foregoing widget sets margin and subsequent widgets have width of 1fr #5116

Closed
mzebrak opened this issue Oct 14, 2024 · 2 comments · Fixed by #5121

Comments

@mzebrak
Copy link

mzebrak commented Oct 14, 2024

Version: 0.83.0

I think the MRE explains everything. I can't think of any rational reason why it behaves this way. Do you have any ideas? This has been observable for a long time - look below.

MRE:

from __future__ import annotations

from textual.app import App, ComposeResult
from textual.containers import Center, Container
from textual.widgets import Label


class MyApp(App):
    CSS = """
    #first-container {
        margin: 10;
        background: green;
        height: auto;
    }

    #second-container {
        background: red;
        height: auto;
        # width: 100%;   #  <--- Uncomment for a workaround
    }

    #third-container {
        background: blue;
        # width: 100%;   #  <--- Uncomment for a workaround
    }
    """

    def compose(self) -> ComposeResult:
        with Container(id="first-container"):
            yield Label("I should have some margin all around")
        with Container(id="second-container"):
            yield Label("I should have NO margin, but I have some on the right...")
        with Center(id="third-container"):
            yield Label("Here also should be no margin, but there is some on the right...")


MyApp().run()

0.16.0 Correct behavior

image

0.20.0 third-container has weird behavior

image

0.40.0 / 0.83.0 both second-container and third-container have weird behavior

image

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

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.

1 participant