-
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
Showing a widget on a higher layer changes the layout on a lower layer #1358
Comments
I faced the same behaviour when developing a drop-down with a layer. I could not solve it so far, but noticed something, which could help: When you comment out the line I solved my problem temporarily by putting the drop-down list into a children layer (not directly to the app), maybe this also helps in your case? Something like: yield Header()
yield Footer()
pane1 = Vertical(Label('Pane 1'), id='pane1')
pane2 = Vertical(Label('Pane 2'),
Label('Press any key to dismiss the dialog'),
id='pane2')
pane3 = Container(Label('Pane 3'), id='pane3')
self.panes = Horizontal(pane1, pane2, pane3, id='panes')
# new:
yield Container(
self.panes,
self.dialog
) |
Thanks for the suggestion, I'll try it out. |
Good find. That workaround is great, in the test app, at least! |
See Textualize/textual#1358 for a similar issue. I'm still undecided at the moment if this is a bug, or correct behaviour. Feels like a bug, but the workaround feels like good practice too.
This issue has something to do with the The example has a few red-herrings. You can reproduce it even without |
Trying to get a pretty minimal reproduction of what seems to be a problem and I've got it down to this: from textual.app import App, ComposeResult
from textual.containers import Vertical
from textual.widgets import Header, Footer, Label
from textual.binding import Binding
class Dialog( Vertical ):
def compose( self ) -> ComposeResult:
"""Compose the child widgets."""
yield Label( "This should not cause a scrollbar to appear" )
class DialogIssueApp( App[ None ] ):
CSS = """
Screen {
layers: base dialog;
}
.hidden {
display: none;
}
Dialog {
align: center middle;
border: round red;
width: 50%;
height: 50%;
layer: dialog;
offset: 50% 50%;
}
"""
BINDINGS = [
Binding( "d", "dialog", "Toggle the dialog" ),
]
def compose( self ) -> ComposeResult:
yield Header()
yield Vertical()
yield Dialog( classes="hidden" )
yield Footer()
def action_dialog( self ) -> None:
self.query_one( Dialog ).toggle_class( "hidden" )
if __name__ == "__main__":
DialogIssueApp().run() I was going to dive into what might be causing this, but coincidentally #1891 is being worked on at the moment, which in turn is a reaction to #1888, all of which could be related. So I'm leaving this test code here and we'll revisit once the outcome of those other changes is known. |
Will need to confirm if this is still an issue. |
As of 0.15.1 this is still an issue. If I run the code above, when the "dalog" pops up, a vertical scrollbar appears. |
Don't forget to star the repository! Follow @textualizeio for Textual updates. |
Discussed in #1321
Originally posted by vsajip December 5, 2022
In the following script (slightly modified from that in the discussion), I attempt to implement a dialog using layers.
When Ctrl+D is pressed to show the dialog, after the dialog is displayed, even though it's in its own layer, the layout of the base layer seems to change slightly (width decreases by two, it seems, because a vertical scrollbar appears for no obvious reason). When the dialog is hidden, the layout reverts to what it was before the dialog was displayed. The following should illustrate the problem:
Note: This only happens on some terminals, not on all. I can get it repeatably on Linux Mint 64-bit with Cinnamon desktop.
I log the sizes of the
Horizontal
container on the base layer just before and after the dialog is displayed. This is what I get in the log:On terminals which don't exhibit the problem, the width remains unchanged.
This is with Textual from the repo (0.6.0+).
The text was updated successfully, but these errors were encountered: