-
Notifications
You must be signed in to change notification settings - Fork 844
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
When an OptionList
has a transparent
background option colours can get out of sync (since 0.86.0)
#5488
Comments
OptionList
has a transparent
background option colours can get out of syncOptionList
has a transparent
background option colours can get out of sync (since 0.86.0
OptionList
has a transparent
background option colours can get out of sync (since 0.86.0OptionList
has a transparent
background option colours can get out of sync (since 0.86.0)
With #5431 in mind, I've checked, and this effect only seems to come in with Textual 0.86 too. |
For what it's worth, I don't think this is unique to the I think the issue is more apparent if you click to focus the Although this particular problem doesn't seem unique to the from textual.app import App, ComposeResult
from textual.containers import Vertical
from textual.widgets import Input, Tree
class Panel(Vertical, can_focus=True):
pass
class FocusWithinTransparentApp(App[None]):
CSS = """
Screen {
layout: horizontal;
}
Input {
width: 1fr;
height: 1fr;
}
Panel {
padding: 5 10;
background: red;
&:focus, &:focus-within {
background: yellow;
}
Tree, Tree:focus {
height: 1fr;
background: transparent;
}
}
"""
def compose(self) -> ComposeResult:
yield Input(placeholder="This is here to escape to")
with Panel():
tree: Tree[str] = Tree("Dune")
tree.root.expand()
characters = tree.root.add("Characters", expand=True)
characters.add_leaf("Paul")
characters.add_leaf("Jessica")
characters.add_leaf("Chani")
yield tree
yield Input(placeholder="Escape out via here for the bug")
if __name__ == "__main__":
FocusWithinTransparentApp().run() |
A possible workaround for this issue in the meantime is repeating the same CSS within the &:focus-within {
background: yellow;
OptionList, OptionList:focus {
background: transparent;
}
} Full code examplefrom textual.app import App, ComposeResult
from textual.containers import Vertical
from textual.widgets import Input, OptionList
class Panel(Vertical, can_focus=True):
pass
class FocusWithinTransparentApp(App[None]):
CSS = """
Screen {
layout: horizontal;
}
Input {
width: 1fr;
height: 1fr;
}
Panel {
padding: 5 10;
background: red;
OptionList, OptionList:focus {
height: 1fr;
background: transparent;
}
&:focus {
background: yellow;
}
&:focus-within {
background: yellow;
OptionList, OptionList:focus {
background: transparent;
}
}
}
"""
def compose(self) -> ComposeResult:
yield Input(placeholder="This is here to escape to")
with Panel():
yield OptionList(*["This is an option" for _ in range(30)])
yield Input(placeholder="Escape out via here for the bug")
if __name__ == "__main__":
FocusWithinTransparentApp().run() |
Given this code:
If you tab into the right panel the background of the
OptionList
updates as you'd expect (goes from red to yellow, as per its background), but if you keep tabbing through and land back in the left panel, theOptionList
's options' backgrounds will be out of sync with its parent (they will remain with a yellow background when it should be red). Actions that cause a refresh of some sort (resize of window, some mouse movements) cause the background to refresh to the correct colour.Screen.Recording.2025-01-20.at.10.57.03.mov
Textual Diagnostics
Versions
Python
Operating System
Terminal
Rich Console options
The text was updated successfully, but these errors were encountered: