diff --git a/CHANGELOG.md b/CHANGELOG.md
index 91045d60b..0e7bd4878 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
### Fixed
- Fixed container not resizing when a widget is removed https://github.com/Textualize/textual/issues/2007
+- Fixes issue where the horizontal scrollbar would be incorrectly enabled https://github.com/Textualize/textual/pull/2024
### Added
diff --git a/docs/examples/styles/scrollbar_size.py b/docs/examples/styles/scrollbar_size.py
index 1bbcec572..bf4390c31 100644
--- a/docs/examples/styles/scrollbar_size.py
+++ b/docs/examples/styles/scrollbar_size.py
@@ -1,5 +1,5 @@
from textual.app import App
-from textual.containers import Vertical
+from textual.containers import Container
from textual.widgets import Label
TEXT = """I must not fear.
@@ -14,7 +14,7 @@ Where the fear has gone there will be nothing. Only I will remain.
class ScrollbarApp(App):
def compose(self):
- yield Vertical(Label(TEXT * 5), classes="panel")
+ yield Container(Label(TEXT * 5), classes="panel")
app = ScrollbarApp(css_path="scrollbar_size.css")
diff --git a/src/textual/widget.py b/src/textual/widget.py
index b9ffc8ef5..5cc76f767 100644
--- a/src/textual/widget.py
+++ b/src/textual/widget.py
@@ -1010,11 +1010,11 @@ class Widget(DOMNode):
show_vertical = self.virtual_size.height > height
# When a single scrollbar is shown, the other dimension changes, so we need to recalculate.
- if show_vertical and not show_horizontal:
+ if overflow_x == "auto" and show_vertical and not show_horizontal:
show_horizontal = self.virtual_size.width > (
width - styles.scrollbar_size_vertical
)
- if show_horizontal and not show_vertical:
+ if overflow_y == "auto" and show_horizontal and not show_vertical:
show_vertical = self.virtual_size.height > (
height - styles.scrollbar_size_horizontal
)
diff --git a/tests/snapshot_tests/__snapshots__/test_snapshots.ambr b/tests/snapshot_tests/__snapshots__/test_snapshots.ambr
index 7629fbc21..cb7b92d30 100644
--- a/tests/snapshot_tests/__snapshots__/test_snapshots.ambr
+++ b/tests/snapshot_tests/__snapshots__/test_snapshots.ambr
@@ -1,3 +1,228 @@
+# name: test_auto_table
+ '''
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ MyApp
+
+
+
+
+
+
+
+
+
+ ⭘ MyApp
+ ╭ ────────────────── ╮ ╭ ────────────────────────────────────────────────────────────────────────────────────────────────── ╮
+ │ ok │ │ test │
+ │ ╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍ │ │ ╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍ │
+ │ │ │ ╭ ─ 0 ────────────────────────────────────── ╮ ╭ ─ 1 ────────────────────────────────────── ╮ ╭ ─ 2 ───── │
+ │ │ │ │ │ │ │ │ │
+ │ │ │ │ Foo Bar Baz │ │ Foo Bar Baz │ │ Foo │
+ │ │ │ │ ABCDEFGH 0123456789 IJKLMNOPQRSTUVWXY │ │ ABCDEFGH 0123456789 IJKLMNOPQRSTUVWXY │ │ ABCDEFGH │
+ │ │ │ │ ABCDEFGH 0123456789 IJKLMNOPQRSTUVWXY │ │ ABCDEFGH 0123456789 IJKLMNOPQRSTUVWXY │ │ ABCDEFGH │
+ │ │ │ │ ABCDEFGH 0123456789 IJKLMNOPQRSTUVWXY │ │ ABCDEFGH 0123456789 IJKLMNOPQRSTUVWXY │ │ ABCDEFGH │
+ │ │ │ │ ABCDEFGH 0123456789 IJKLMNOPQRSTUVWXY │ │ ABCDEFGH 0123456789 IJKLMNOPQRSTUVWXY │ │ ABCDEFGH │
+ │ │ │ │ ABCDEFGH 0123456789 IJKLMNOPQRSTUVWXY │ │ ABCDEFGH 0123456789 IJKLMNOPQRSTUVWXY │ │ ABCDEFGH │
+ │ │ │ │ ABCDEFGH 0123456789 IJKLMNOPQRSTUVWXY │ │ ABCDEFGH 0123456789 IJKLMNOPQRSTUVWXY │ │ ABCDEFGH │
+ │ │ │ │ ABCDEFGH 0123456789 IJKLMNOPQRSTUVWXY │ │ ABCDEFGH 0123456789 IJKLMNOPQRSTUVWXY │ │ ABCDEFGH │
+ │ │ │ │ ABCDEFGH 0123456789 IJKLMNOPQRSTUVWXY │ │ ABCDEFGH 0123456789 IJKLMNOPQRSTUVWXY │ │ ABCDEFGH │
+ │ │ │ │ ABCDEFGH 0123456789 IJKLMNOPQRSTUVWXY │ │ ABCDEFGH 0123456789 IJKLMNOPQRSTUVWXY │ │ ABCDEFGH │
+ │ │ │ │ ABCDEFGH 0123456789 IJKLMNOPQRSTUVWXY │ │ ABCDEFGH 0123456789 IJKLMNOPQRSTUVWXY │ │ ABCDEFGH │
+ │ │ │ │ ABCDEFGH 0123456789 IJKLMNOPQRSTUVWXY │ │ ABCDEFGH 0123456789 IJKLMNOPQRSTUVWXY │ │ ABCDEFGH │
+ │ │ │ │ ABCDEFGH 0123456789 IJKLMNOPQRSTUVWXY │ │ ABCDEFGH 0123456789 IJKLMNOPQRSTUVWXY │ │ ABCDEFGH │
+ │ │ │ │ ABCDEFGH 0123456789 IJKLMNOPQRSTUVWXY │ │ ABCDEFGH 0123456789 IJKLMNOPQRSTUVWXY │ │ ABCDEFGH │
+ │ │ │ │ ABCDEFGH 0123456789 IJKLMNOPQRSTUVWXY │ │ ABCDEFGH 0123456789 IJKLMNOPQRSTUVWXY │ │ ABCDEFGH │
+ │ │ │ │ ABCDEFGH 0123456789 IJKLMNOPQRSTUVWXY │ │ ABCDEFGH 0123456789 IJKLMNOPQRSTUVWXY │ │ ABCDEFGH │
+ │ │ │ │ ABCDEFGH 0123456789 IJKLMNOPQRSTUVWXY │ │ ABCDEFGH 0123456789 IJKLMNOPQRSTUVWXY │ │ ABCDEFGH │
+ │ │ │ │ ABCDEFGH 0123456789 IJKLMNOPQRSTUVWXY │ │ ABCDEFGH 0123456789 IJKLMNOPQRSTUVWXY │ │ ABCDEFGH │
+ │ │ │ │ ABCDEFGH 0123456789 IJKLMNOPQRSTUVWXY ▁▁ │ │ ABCDEFGH 0123456789 IJKLMNOPQRSTUVWXY ▁▁ │ │ ABCDEFGH │
+ │ │ │ │ ABCDEFGH 0123456789 IJKLMNOPQRSTUVWXY │ │ ABCDEFGH 0123456789 IJKLMNOPQRSTUVWXY │ │ ABCDEFGH │
+ │ │ │ │ ABCDEFGH 0123456789 IJKLMNOPQRSTUVWXY │ │ ABCDEFGH 0123456789 IJKLMNOPQRSTUVWXY │ │ ABCDEFGH │
+ │ │ │ │ ABCDEFGH 0123456789 IJKLMNOPQRSTUVWXY │ │ ABCDEFGH 0123456789 IJKLMNOPQRSTUVWXY │ │ ABCDEFGH │
+ │ │ │ │ ABCDEFGH 0123456789 IJKLMNOPQRSTUVWXY │ │ ABCDEFGH 0123456789 IJKLMNOPQRSTUVWXY │ │ ABCDEFGH │
+ │ │ │ │ ABCDEFGH 0123456789 IJKLMNOPQRSTUVWXY │ │ ABCDEFGH 0123456789 IJKLMNOPQRSTUVWXY │ │ ABCDEFGH │
+ │ │ │ │ ABCDEFGH 0123456789 IJKLMNOPQRSTUVWXY │ │ ABCDEFGH 0123456789 IJKLMNOPQRSTUVWXY │ │ ABCDEFGH │
+ │ │ │ │ ABCDEFGH 0123456789 IJKLMNOPQRSTUVWXY │ │ ABCDEFGH 0123456789 IJKLMNOPQRSTUVWXY │ │ ABCDEFGH │
+ │ │ │ │ ABCDEFGH 0123456789 IJKLMNOPQRSTUVWXY │ │ ABCDEFGH 0123456789 IJKLMNOPQRSTUVWXY │ │ ABCDEFGH │
+ │ │ │ │ ABCDEFGH 0123456789 IJKLMNOPQRSTUVWXY │ │ ABCDEFGH 0123456789 IJKLMNOPQRSTUVWXY │ │ ABCDEFGH │
+ │ │ │ │ ABCDEFGH 0123456789 IJKLMNOPQRSTUVWXY │ │ ABCDEFGH 0123456789 IJKLMNOPQRSTUVWXY │ │ ABCDEFGH │
+ │ │ │ │ ABCDEFGH 0123456789 IJKLMNOPQRSTUVWXY │ │ ABCDEFGH 0123456789 IJKLMNOPQRSTUVWXY │ │ ABCDEFGH │
+ │ │ │ │ ABCDEFGH 0123456789 IJKLMNOPQRSTUVWXY │ │ ABCDEFGH 0123456789 IJKLMNOPQRSTUVWXY │ │ ABCDEFGH │
+ │ │ │ ╰ ────────────────────────────────────────── ╯ ╰ ────────────────────────────────────────── ╯ ╰ ───────── │
+ │ │ │ ▋ │
+ ╰ ────────────────── ╯ ╰ ────────────────────────────────────────────────────────────────────────────────────────────────── ╯
+
+
+
+
+ '''
+# ---
# name: test_auto_width_input
'''
@@ -12103,163 +12328,164 @@
font-weight: 700;
}
- .terminal-3822425727-matrix {
+ .terminal-717671184-matrix {
font-family: Fira Code, monospace;
font-size: 20px;
line-height: 24.4px;
font-variant-east-asian: full-width;
}
- .terminal-3822425727-title {
+ .terminal-717671184-title {
font-size: 18px;
font-weight: bold;
font-family: arial;
}
- .terminal-3822425727-r1 { fill: #c5c8c6 }
- .terminal-3822425727-r2 { fill: #e3e3e3 }
- .terminal-3822425727-r3 { fill: #313437 }
- .terminal-3822425727-r4 { fill: #324f70 }
- .terminal-3822425727-r5 { fill: #4f9262 }
- .terminal-3822425727-r6 { fill: #a4823a }
- .terminal-3822425727-r7 { fill: #904354 }
- .terminal-3822425727-r8 { fill: #7c7d7e;font-weight: bold }
- .terminal-3822425727-r9 { fill: #75828b;font-weight: bold }
- .terminal-3822425727-r10 { fill: #192e1f;font-weight: bold }
- .terminal-3822425727-r11 { fill: #3a2a13;font-weight: bold }
- .terminal-3822425727-r12 { fill: #978186;font-weight: bold }
- .terminal-3822425727-r13 { fill: #101011 }
- .terminal-3822425727-r14 { fill: #0c1e39 }
- .terminal-3822425727-r15 { fill: #156034 }
- .terminal-3822425727-r16 { fill: #825210 }
- .terminal-3822425727-r17 { fill: #5b132a }
- .terminal-3822425727-r18 { fill: #768189 }
- .terminal-3822425727-r19 { fill: #e1e1e1 }
- .terminal-3822425727-r20 { fill: #3a2a13 }
- .terminal-3822425727-r21 { fill: #7b7b7b }
- .terminal-3822425727-r22 { fill: #78838b }
- .terminal-3822425727-r23 { fill: #7f8081 }
- .terminal-3822425727-r24 { fill: #7c7d7e }
- .terminal-3822425727-r25 { fill: #31220c;font-weight: bold }
- .terminal-3822425727-r26 { fill: #e2e3e3 }
- .terminal-3822425727-r27 { fill: #104e2d }
- .terminal-3822425727-r28 { fill: #7a7b7b }
- .terminal-3822425727-r29 { fill: #1c1c1c }
- .terminal-3822425727-r30 { fill: #191919 }
- .terminal-3822425727-r31 { fill: #181818 }
- .terminal-3822425727-r32 { fill: #7c7c7c }
- .terminal-3822425727-r33 { fill: #494949 }
- .terminal-3822425727-r34 { fill: #ddedf9 }
+ .terminal-717671184-r1 { fill: #c5c8c6 }
+ .terminal-717671184-r2 { fill: #e3e3e3 }
+ .terminal-717671184-r3 { fill: #313437 }
+ .terminal-717671184-r4 { fill: #324f70 }
+ .terminal-717671184-r5 { fill: #4f9262 }
+ .terminal-717671184-r6 { fill: #a4823a }
+ .terminal-717671184-r7 { fill: #904354 }
+ .terminal-717671184-r8 { fill: #e1e1e1 }
+ .terminal-717671184-r9 { fill: #7c7d7e;font-weight: bold }
+ .terminal-717671184-r10 { fill: #75828b;font-weight: bold }
+ .terminal-717671184-r11 { fill: #192e1f;font-weight: bold }
+ .terminal-717671184-r12 { fill: #3a2a13;font-weight: bold }
+ .terminal-717671184-r13 { fill: #978186;font-weight: bold }
+ .terminal-717671184-r14 { fill: #101011 }
+ .terminal-717671184-r15 { fill: #0c1e39 }
+ .terminal-717671184-r16 { fill: #156034 }
+ .terminal-717671184-r17 { fill: #825210 }
+ .terminal-717671184-r18 { fill: #5b132a }
+ .terminal-717671184-r19 { fill: #768189 }
+ .terminal-717671184-r20 { fill: #3a2a13 }
+ .terminal-717671184-r21 { fill: #7b7b7b }
+ .terminal-717671184-r22 { fill: #78838b }
+ .terminal-717671184-r23 { fill: #7f8081 }
+ .terminal-717671184-r24 { fill: #7c7d7e }
+ .terminal-717671184-r25 { fill: #31220c;font-weight: bold }
+ .terminal-717671184-r26 { fill: #e2e3e3 }
+ .terminal-717671184-r27 { fill: #104e2d }
+ .terminal-717671184-r28 { fill: #7a7b7b }
+ .terminal-717671184-r29 { fill: #1c1c1c }
+ .terminal-717671184-r30 { fill: #191919 }
+ .terminal-717671184-r31 { fill: #181818 }
+ .terminal-717671184-r32 { fill: #7c7c7c }
+ .terminal-717671184-r33 { fill: #494949 }
+ .terminal-717671184-r34 { fill: #14191f }
+ .terminal-717671184-r35 { fill: #ddedf9 }
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
- WidgetDisableTestApp
+ WidgetDisableTestApp
-
-
-
- ⭘ WidgetDisableTestApp
- ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔ ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔ ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔ ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔ ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- Button Button Button Button Button
- ▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁ ▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁ ▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁ ▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁ ▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁
- Column 1 Column 2 Column 3 Column 4
- 0 0 0 0
- This is list item 0
- This is list item 1
- ▼ This is a test tree
- ├── Leaf 0
- Hello, World!
-
- ▊ ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔ ▎
- ▊ ▎
- ▊ ▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁ ▎
- ▊ ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔ ▎
- ▊ This is an empty input with a placeholder ▎
- ▊ ▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁ ▎
- ▊ ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔ ▎
- ▊ This is some text in an input ▎
- ▊ ▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁ ▎
- ▁ ▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁ ▁
-
+
+
+
+ ⭘ WidgetDisableTestApp
+ ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔ ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔ ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔ ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔ ▔▔▔▔▔▔▔▔▔▔▔▔▔▔
+ Button Button Button Button Button
+ ▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁ ▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁ ▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁ ▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁ ▁▁▁▁▁▁▁▁▁▁▁▁▁▁
+ Column 1 Column 2 Column 3 Column 4
+ 0 0 0 0
+ This is list item 0
+ This is list item 1
+ ▼ This is a test tree
+ ├── Leaf 0
+ Hello, World!
+
+ ▊ ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔ ▎
+ ▊ ▎
+ ▊ ▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁ ▎
+ ▊ ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔ ▎
+ ▊ This is an empty input with a placeholder ▎
+ ▊ ▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁ ▎
+ ▊ ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔ ▎
+ ▊ This is some text in an input ▎
+ ▊ ▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁ ▎
+ ▁ ▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁ ▁
+ ▇▇
diff --git a/tests/snapshot_tests/snapshot_apps/auto-table.py b/tests/snapshot_tests/snapshot_apps/auto-table.py
new file mode 100644
index 000000000..49a6c1842
--- /dev/null
+++ b/tests/snapshot_tests/snapshot_apps/auto-table.py
@@ -0,0 +1,189 @@
+from os import urandom
+from random import randrange
+
+from textual.app import App
+from textual.containers import Container, Horizontal, Vertical
+from textual.screen import Screen
+from textual.widgets import DataTable, Header, Label
+
+
+class LabeledBox(Container):
+ DEFAULT_CSS = """
+ LabeledBox {
+ layers: base_ top_;
+ width: 100%;
+ height: 100%;
+ }
+
+ LabeledBox > Container {
+ layer: base_;
+ border: round $primary;
+ width: 100%;
+ height: 100%;
+ layout: vertical;
+ }
+
+ LabeledBox > Label {
+ layer: top_;
+ offset-x: 2;
+ }
+ """
+
+ def __init__(self, title, *args, **kwargs):
+ self.__label = Label(title)
+
+ super().__init__(self.__label, Container(*args, **kwargs))
+
+ @property
+ def label(self):
+ return self.__label
+
+
+class StatusTable(DataTable):
+ def __init__(self):
+ super().__init__()
+
+ self.cursor_type = "row"
+ self.show_cursor = False
+ self.add_column("Foo")
+ self.add_column("Bar")
+ self.add_column("Baz")
+
+ for _ in range(50):
+ self.add_row(
+ "ABCDEFGH",
+ "0123456789",
+ "IJKLMNOPQRSTUVWXYZ",
+ )
+
+
+class Status(LabeledBox):
+ DEFAULT_CSS = """
+ Status {
+ width: auto;
+ }
+
+ Status Container {
+ width: auto;
+ }
+
+ Status StatusTable {
+ width: auto;
+ margin-top: 1;
+ scrollbar-gutter: stable;
+ overflow-x: hidden;
+ }
+ """
+
+ def __init__(self, name: str):
+ self.__name = name
+ self.__table = StatusTable()
+
+ super().__init__(f" {self.__name} ", self.__table)
+
+ @property
+ def name(self) -> str:
+ return self.__name
+
+ @property
+ def table(self) -> StatusTable:
+ return self.__table
+
+
+class Rendering(LabeledBox):
+ DEFAULT_CSS = """
+ #issue-info {
+ height: auto;
+ border-bottom: dashed #632CA6;
+ }
+
+ #statuses-box {
+ height: 1fr;
+ width: auto;
+ }
+ """
+
+ def __init__(self):
+ self.__info = Label("test")
+
+ super().__init__(
+ "",
+ Container(
+ Horizontal(self.__info, id="issue-info"),
+ Horizontal(*[Status(str(i)) for i in range(4)], id="statuses-box"),
+ id="issues-box",
+ ),
+ )
+
+ @property
+ def info(self) -> Label:
+ return self.__info
+
+
+class Sidebar(LabeledBox):
+ DEFAULT_CSS = """
+ #sidebar-status {
+ height: auto;
+ border-bottom: dashed #632CA6;
+ }
+
+ #sidebar-options {
+ height: 1fr;
+ }
+ """
+
+ def __init__(self):
+ self.__status = Label("ok")
+ self.__options = Vertical()
+
+ super().__init__(
+ "",
+ Container(self.__status, id="sidebar-status"),
+ Container(self.__options, id="sidebar-options"),
+ )
+
+ @property
+ def status(self) -> Label:
+ return self.__status
+
+ @property
+ def options(self) -> Vertical:
+ return self.__options
+
+
+class MyScreen(Screen):
+ DEFAULT_CSS = """
+ #main-content {
+ layout: grid;
+ grid-size: 2;
+ grid-columns: 1fr 5fr;
+ grid-rows: 1fr;
+ }
+
+ #main-content-sidebar {
+ height: 100%;
+ }
+
+ #main-content-rendering {
+ height: 100%;
+ }
+ """
+
+ def compose(self):
+ yield Header()
+ yield Container(
+ Container(Sidebar(), id="main-content-sidebar"),
+ Container(Rendering(), id="main-content-rendering"),
+ id="main-content",
+ )
+
+
+class MyApp(App):
+ async def on_mount(self):
+ self.install_screen(MyScreen(), "myscreen")
+ await self.push_screen("myscreen")
+
+
+if __name__ == "__main__":
+ app = MyApp()
+ app.run()
diff --git a/tests/snapshot_tests/snapshot_apps/disable_widgets.py b/tests/snapshot_tests/snapshot_apps/disable_widgets.py
index 7a241e914..8965fbdac 100644
--- a/tests/snapshot_tests/snapshot_apps/disable_widgets.py
+++ b/tests/snapshot_tests/snapshot_apps/disable_widgets.py
@@ -17,7 +17,6 @@ from textual.widgets import (
class WidgetDisableTestApp(App[None]):
-
CSS = """
Horizontal {
height: auto;
diff --git a/tests/snapshot_tests/test_snapshots.py b/tests/snapshot_tests/test_snapshots.py
index d6ae89998..0b26c83c9 100644
--- a/tests/snapshot_tests/test_snapshots.py
+++ b/tests/snapshot_tests/test_snapshots.py
@@ -305,3 +305,7 @@ def test_remove_with_auto_height(snap_compare):
assert snap_compare(
SNAPSHOT_APPS_DIR / "remove_auto.py", press=["a", "a", "a", "d", "d"]
)
+
+
+def test_auto_table(snap_compare):
+ assert snap_compare(SNAPSHOT_APPS_DIR / "auto-table.py", terminal_size=(120, 40))