Repository: Textualize/textual

Issue:
Tab scrolling not working
Tabs do not scroll as they used to.

This is Textual 0.51.0 (latests at time of writing)

https://github.com/Textualize/textual/assets/554369/5254051a-d8b4-416a-80d9-396e336bf3b1

This is Textual 0.50.1

https://github.com/Textualize/textual/assets/554369/e3a0fd66-206b-47f1-9eb6-4a8d6dc4def9

I'm assuming something was broken with @davep 's recent fix to `active` reactive.

Tab scrolling not working
Tabs do not scroll as they used to.

This is Textual 0.51.0 (latests at time of writing)

https://github.com/Textualize/textual/assets/554369/5254051a-d8b4-416a-80d9-396e336bf3b1

This is Textual 0.50.1

https://github.com/Textualize/textual/assets/554369/e3a0fd66-206b-47f1-9eb6-4a8d6dc4def9

I'm assuming something was broken with @davep 's recent fix to `active` reactive.



Discussion:
It's kinda tricky to see the difference between the two videos, but is the v0.51.0 one a little too eager to get to the new tab when using a mouse click? I suspect this is needed then:

```diff
diff --git a/src/textual/widgets/_tabs.py b/src/textual/widgets/_tabs.py
index 276f7e58..1948bb9c 100644
--- a/src/textual/widgets/_tabs.py
+++ b/src/textual/widgets/_tabs.py
@@ -644,7 +644,6 @@ class Tabs(Widget, can_focus=True):
         self.query("#tabs-list Tab.-active").remove_class("-active")
         tab.add_class("-active")
         self.active = tab.id or ""
-        self.query_one("#tabs-scroll").scroll_to_center(tab, force=True)
 
     def _on_underline_clicked(self, event: Underline.Clicked) -> None:
         """The underline was clicked.
```

can you check and see if that removes what you're seeing?
That doesn't appear to change anything.
Curious. Now that I'm at a keyboard and can try and recreate all of this, with 0.51 (on the left in this video) I'm seeing an immediate jump (which is what I thought I was seeing in your video); if I make the change suggested above (make to `Tabs._activate_tab`) I see the smoother scrolling I'd expect again:

https://github.com/Textualize/textual/assets/28237/87948c9f-9611-4a26-bab6-441e97239108

I'll PR this change anyway so you can try again; perhaps the diff above (which I offered for illustrative purposes; of course it could be that your `main` differed by the time you tried it out).
It's kinda tricky to see the difference between the two videos, but is the v0.51.0 one a little too eager to get to the new tab when using a mouse click? I suspect this is needed then:

```diff
diff --git a/src/textual/widgets/_tabs.py b/src/textual/widgets/_tabs.py
index 276f7e58..1948bb9c 100644
--- a/src/textual/widgets/_tabs.py
+++ b/src/textual/widgets/_tabs.py
@@ -644,7 +644,6 @@ class Tabs(Widget, can_focus=True):
         self.query("#tabs-list Tab.-active").remove_class("-active")
         tab.add_class("-active")
         self.active = tab.id or ""
-        self.query_one("#tabs-scroll").scroll_to_center(tab, force=True)
 
     def _on_underline_clicked(self, event: Underline.Clicked) -> None:
         """The underline was clicked.
```

can you check and see if that removes what you're seeing?
That doesn't appear to change anything.
Curious. Now that I'm at a keyboard and can try and recreate all of this, with 0.51 (on the left in this video) I'm seeing an immediate jump (which is what I thought I was seeing in your video); if I make the change suggested above (make to `Tabs._activate_tab`) I see the smoother scrolling I'd expect again:

https://github.com/Textualize/textual/assets/28237/87948c9f-9611-4a26-bab6-441e97239108

I'll PR this change anyway so you can try again; perhaps the diff above (which I offered for illustrative purposes; of course it could be that your `main` differed by the time you tried it out).

Resolving patch:
diff --git a/src/textual/widgets/_tabs.py b/src/textual/widgets/_tabs.py
--- a/src/textual/widgets/_tabs.py
+++ b/src/textual/widgets/_tabs.py
@@ -644,7 +644,6 @@ def _activate_tab(self, tab: Tab) -> None:
         self.query("#tabs-list Tab.-active").remove_class("-active")
         tab.add_class("-active")
         self.active = tab.id or ""
-        self.query_one("#tabs-scroll").scroll_to_center(tab, force=True)
 
     def _on_underline_clicked(self, event: Underline.Clicked) -> None:
         """The underline was clicked.
@@ -700,7 +699,6 @@ def _move_tab(self, direction: int) -> None:
         tab_count = len(tabs)
         new_tab_index = (tabs.index(active_tab) + direction) % tab_count
         self.active = tabs[new_tab_index].id or ""
-        self._scroll_active_tab()
 
     def _on_tab_disabled(self, event: Tab.Disabled) -> None:
         """Re-post the disabled message."""


Test patch: