-
Notifications
You must be signed in to change notification settings - Fork 815
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
Margin-right does not work properly when RadioSet is present on the screen. #4332
Comments
I've not dived onto the why of this yet, but this doesn't seem to be anything to do with |
This looks to me like the effect of a widget with 100% width (i.e. the Input) inside a container with a width of 1fr? Here's a slighlly reduced example. Compare before and after uncommenting the CSS on line 16: from textual.containers import Container, ScrollableContainer
from textual.widgets import Input, Button
from textual.app import App, ComposeResult
class ExampleApp(App):
CSS = """
#outer {
border: solid red;
}
#inner {
margin-right: 20;
border: solid blue;
/* width: 100%; */
}
"""
def compose(self) -> ComposeResult:
with ScrollableContainer(id="outer"):
yield Button()
with Container(id="inner"):
yield Input()
if __name__ == "__main__":
app = ExampleApp()
app.run() |
It took me a minute to figure out why changing the width then wasn't working in your example above, but it looks like your CSS was missing the parent selector like this: class MyTabPane(TabPane):
DEFAULT_CSS = """
MyTabPane Grid { I confess I don't understand why the rest of the CSS still seems to work though! I'm still not caught up on nested CSS so not sure if this might have revealed some sort of bug...? |
Honestly it looks like a workaround to me..., because what is the reason why |
I wonder if this is actually another instance of #4360. |
Yes, thanks for your help! I look forward to the solution. |
IMO, worth knowing, we observed this problem on version |
Ahh, okay, likely not related then. |
Just to clarify, there was a change in this margin behaviour but back in v0.48.0 following #4037. @jakubziebin I was only trying to clarify the likely cause with a MRE (as actually nothing to do with a RadioSet). I'm not saying this behaviour is correct or incorrect (and as you'll see from the discussion in the PR above, margin behaviour is a bit of a contentious issue!) |
I encountered one more strange behavior of the margin:
Part of the button is cut off because of the bottom margin of the input. I wasn't sure if this should be posted in another issue, but I thought it was somewhat related, let me know if it should be converted to another issue. |
I don't think it is the margin. If you try deleting the CSS for the Input from your example, you'll see the button is still cut off. Looks to me something about the EDIT: Interestingly, if you add a second Button all seems to work as expected. from textual.app import App, ComposeResult
from textual.containers import Container
from textual.widgets import Button
class ExampleApp(App):
CSS = """
#outer-container {
height: auto;
border: solid red;
}
#btn-container {
/* align: center middle; */
height: auto;
border: solid blue;
}
"""
def compose(self) -> ComposeResult:
with Container(id="outer-container"):
with Container(id="btn-container"):
yield Button()
# yield Button()
if __name__ == "__main__":
ExampleApp().run() |
Don't forget to star the repository! Follow @textualizeio for Textual updates. |
I have observed strange margin-right behavior when
RadioSet
is present on the screen. Consider an example like this:When running the application, the entire margin will be placed outside the screen content and will be accessible by scrolling. When removing
ScrollableContainer
the margin will not be visible. I have not observed similar situations withoutRadioSet
.The text was updated successfully, but these errors were encountered: