-
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
Giving focus to a widget not scrolled into view doesn't always scroll it into view #4461
Comments
I'm pretty sure this is something to do with the animation that occurs when you |
I can't reproduce the issue in Elia though in a chat with only a couple of messages - I'd have expected it to exhibit the same behaviour given this MRE - I wonder if it's related to the distance that needs to be scrolled or the number of children. |
I've not dived too deep into this yet, but if you add a debug log here: diff --git a/src/textual/screen.py b/src/textual/screen.py
index b84fbc277..6dd3d0a43 100644
--- a/src/textual/screen.py
+++ b/src/textual/screen.py
@@ -632,6 +632,7 @@ class Screen(Generic[ScreenResultType], Widget):
def scroll_to_center(widget: Widget) -> None:
"""Scroll to center (after a refresh)."""
+ self.log.debug(f"{widget.has_focus = }")
if widget.has_focus and not self.screen.can_view(widget):
self.screen.scroll_to_center(widget, origin_visible=True) It looks like the |
Weird, because I added an "animate=False" inside that same block and it seemed to fix the issue. At least, I think it was in there. |
@darrenburns I originally tried the same thing but just happened to reproduce the same issue first try, I think the problem is that the bug is very intermittent. The actual issue seems to be when the |
Don't forget to star the repository! Follow @textualizeio for Textual updates. |
Using the following code:
often, but not always, if I tab or shift+tab from the
Input
to theInner
that isn't currently visible in theTop
widget, the focused widget isn't scrolled into view. A subsequent change of focus "further" in the same direction will then result in the subsequently-focused widget being brought into view.So, using the above, I can often cause the problem like this:
The text was updated successfully, but these errors were encountered: