-
Notifications
You must be signed in to change notification settings - Fork 854
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
The moment of setting the focus has changed (omits can_focus set in on_mount) after the 2.0.0 #5605
Comments
from __future__ import annotations
from textual.app import App, ComposeResult
from textual.containers import VerticalScroll
from textual.widget import Widget
from textual.widgets import Static
class Long(VerticalScroll):
"""Will be focused right after launching in 1.0.0 but not in 2.0.0."""
def allow_focus(self) -> bool:
return any(self.scrollbars_enabled)
def compose(self) -> ComposeResult:
for i in range(50):
yield Static(f"static no. {i}")
class MyApp(App):
def compose(self) -> ComposeResult:
yield Long() |
Don't forget to star the repository! Follow @textualizeio for Textual updates. |
I almost raised an issue about Here's a slightly modified version of your example. When you first start the app, this widget is still focusable despite not having any scrollbars: from __future__ import annotations
from textual.app import App, ComposeResult
from textual.containers import VerticalScroll
from textual.widget import Widget
from textual.widgets import Button, Static
class Long(VerticalScroll):
DEFAULT_CSS = """
Long {
border: tall red;
&:focus {
border: tall green;
}
}
"""
def allow_focus(self) -> bool:
return any(self.scrollbars_enabled)
def compose(self) -> ComposeResult:
for i in range(10):
yield Static(f"static no. {i}")
class MyApp(App):
def compose(self) -> ComposeResult:
yield Long()
yield Button()
if __name__ == "__main__":
app = MyApp()
app.run() |
It stopped working behaving correctly after 2.0.0: Textualize/textual#5605 Still there is a know issue: Textualize/textual#5609
It stopped working behaving correctly after 2.0.0: Textualize/textual#5605 Still there is a know issue: Textualize/textual#5609
It stopped working behaving correctly after 2.0.0: Textualize/textual#5605 Still there is a know issue: Textualize/textual#5609
It stopped working behaving correctly after 2.0.0: Textualize/textual#5605 Still there is a know issue: Textualize/textual#5609
It stopped working behaving correctly after 2.0.0: Textualize/textual#5605 Still there is a know issue: Textualize/textual#5609
Adding basic logging to the from __future__ import annotations
from textual.app import App, ComposeResult
from textual.containers import VerticalScroll
from textual.widget import Widget
from textual.widgets import Button, Static
class Long(VerticalScroll):
DEFAULT_CSS = """
Long {
border: tall red;
&:focus {
border: tall green;
}
}
"""
def allow_focus(self) -> bool:
v = any(self.scrollbars_enabled)
self.log(f"allow_focus value:: {v}")
return v
def compose(self) -> ComposeResult:
for i in range(10):
yield Static(f"static no. {i}")
class MyApp(App):
def compose(self) -> ComposeResult:
yield Long()
yield Button()
if __name__ == "__main__":
app = MyApp()
app.run() |
It stopped working behaving correctly after 2.0.0: Textualize/textual#5605 Still there is a know issue: Textualize/textual#5609
This works correctly in 1.0.0 but changed in 2.0.0.
Right after launch,
Long
widget should have focus (so, e.g.key_down
binding should work and scroll). But it is not focused since 2.0.0.CanFocusOnlyWhenScrollbars
originated from: #3717MRE:
The text was updated successfully, but these errors were encountered: