diff --git a/CHANGELOG.md b/CHANGELOG.md index 67652d343d..0d1e3d1c83 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/). +## Unreleased + +### Fixed + +- Fixed Footer's width calculation when docked to correctly respect margins https://github.com/Textualize/textual/issues/6616 + ## [8.2.8] - 2026-06-30 ### Fixed diff --git a/src/textual/widgets/_footer.py b/src/textual/widgets/_footer.py index 04b2ba5bde..bb33837e3d 100644 --- a/src/textual/widgets/_footer.py +++ b/src/textual/widgets/_footer.py @@ -154,6 +154,7 @@ class Footer(ScrollableContainer, can_focus=False, can_focus_children=False): background: $footer-background; dock: bottom; height: 1; + width: 100%; scrollbar-size: 0 0; &.-compact { FooterLabel { diff --git a/tests/snapshot_tests/__snapshots__/test_snapshots/test_footer_margin.svg b/tests/snapshot_tests/__snapshots__/test_snapshots/test_footer_margin.svg new file mode 100644 index 0000000000..1635c07efc --- /dev/null +++ b/tests/snapshot_tests/__snapshots__/test_snapshots/test_footer_margin.svg @@ -0,0 +1,152 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + FooterMarginApp + + + + + + + + + + + + + + + + + + + + + + + + + + + + q Quit ^p palette + + + + + + + + diff --git a/tests/snapshot_tests/snapshot_apps/footer_margin.py b/tests/snapshot_tests/snapshot_apps/footer_margin.py new file mode 100644 index 0000000000..efd8eacba7 --- /dev/null +++ b/tests/snapshot_tests/snapshot_apps/footer_margin.py @@ -0,0 +1,29 @@ +from textual.app import App, ComposeResult +from textual.widgets import Footer + + +class FooterMarginApp(App): + """Regression test for https://github.com/Textualize/textual/issues/6616 + + Setting a margin on the Footer should shrink it on all sides. Previously + the Footer kept a fixed width, so the left/top margin created a gap but + the right margin had nowhere to go and was invisible.""" + + CSS = """ + Screen { + background: blue; + } + """ + + BINDINGS = [("q", "quit", "Quit")] + + def compose(self) -> ComposeResult: + yield Footer() + + def on_mount(self) -> None: + self.query_one(Footer).styles.margin = 5 + + +if __name__ == "__main__": + app = FooterMarginApp() + app.run() \ No newline at end of file diff --git a/tests/snapshot_tests/test_snapshots.py b/tests/snapshot_tests/test_snapshots.py index 4eac45ec03..8acb25ab89 100644 --- a/tests/snapshot_tests/test_snapshots.py +++ b/tests/snapshot_tests/test_snapshots.py @@ -391,7 +391,11 @@ def test_datatable_change_cell_padding(snap_compare): def test_footer_render(snap_compare): assert snap_compare(WIDGET_EXAMPLES_DIR / "footer.py") +def test_footer_margin(snap_compare): + """Regression test for https://github.com/Textualize/textual/issues/6616""" + assert snap_compare(SNAPSHOT_APPS_DIR / "footer_margin.py") + def test_header_render(snap_compare): assert snap_compare(WIDGET_EXAMPLES_DIR / "header.py")