Repository: Textualize/textual

Issue:
Disabled TabPane can still be Accessed/selected via the underline bar
A Tabpane can be deactivated like this:

```
with TabbedContent():
    with TabPane("HELP", id="HELP-tab" ,disabled=True):
        pass
```
the Title/Label is not clickable any more, yet the pane can still be accessed by clicking on the underline bar.

![grafik](https://github.com/Textualize/textual/assets/49558118/92a79216-a09e-44bf-9e2f-adcec395cdbf)
![grafik](https://github.com/Textualize/textual/assets/49558118/706d5620-55dd-469a-8666-cbf26c56ef69)

IMO this way of interacting with that TabPane should equally be restricted when disabled=True.




Discussion:
merriam: lgtm

Fix is one line.  Verified test fails without the fix and passes with it.  

Patch:
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 1bdc55f5a..638fdab39 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -7,14 +7,15 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
 
 ## Unreleased
 
-### Changed
-
-- "Discover" hits in the command palette are no longer sorted alphabetically https://github.com/Textualize/textual/pull/4720
-
 ### Fixed
 
+- Fixed issue with `Tabs` where disabled tabs could still be activated by clicking the underline https://github.com/Textualize/textual/issues/4701
 - Fixed scroll_visible with margin https://github.com/Textualize/textual/pull/4719
 
+### Changed
+
+- "Discover" hits in the command palette are no longer sorted alphabetically https://github.com/Textualize/textual/pull/4720
+
 ## [0.72.0] - 2024-07-09
 
 ### Changed
diff --git a/src/textual/widgets/_tabs.py b/src/textual/widgets/_tabs.py
index e31ec4bfe..dce53e0e8 100644
--- a/src/textual/widgets/_tabs.py
+++ b/src/textual/widgets/_tabs.py
@@ -673,7 +673,7 @@ class Tabs(Widget, can_focus=True):
         offset = event.offset + (0, -1)
         self.focus()
         for tab in self.query(Tab):
-            if offset in tab.region:
+            if offset in tab.region and not tab.disabled:
                 self._activate_tab(tab)
                 break
 


Test patch:
diff --git a/tests/test_tabs.py b/tests/test_tabs.py
index 8d865552d..0eef93f78 100644
--- a/tests/test_tabs.py
+++ b/tests/test_tabs.py
@@ -491,3 +491,22 @@ async def test_mouse_navigation_messages():
             "on_tabs_tab_activated",
             "on_tabs_tab_activated",
         ]
+
+
+async def test_disabled_tab_is_not_activated_by_clicking_underline():
+    """Regression test for https://github.com/Textualize/textual/issues/4701"""
+
+    class DisabledTabApp(App):
+        def compose(self) -> ComposeResult:
+            yield Tabs(
+                Tab("Enabled", id="enabled"),
+                Tab("Disabled", id="disabled", disabled=True),
+            )
+
+    app = DisabledTabApp()
+    async with app.run_test() as pilot:
+        # Click the underline beneath the disabled tab
+        await pilot.click(Tabs, offset=(14, 2))
+        tabs = pilot.app.query_one(Tabs)
+        assert tabs.active_tab is not None
+        assert tabs.active_tab.id == "enabled"