mirror of
https://github.com/Textualize/textual.git
synced 2025-10-17 02:38:12 +03:00
Merge pull request #4719 from Textualize/fix-scroll-visible-with-margin
Fix for scroll visible
This commit is contained in:
@@ -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 scroll_visible with margin https://github.com/Textualize/textual/pull/4719
|
||||
|
||||
## [0.72.0] - 2024-07-09
|
||||
|
||||
### Changed
|
||||
|
||||
@@ -2781,6 +2781,8 @@ class Widget(DOMNode):
|
||||
region = (
|
||||
(
|
||||
region.translate(-scroll_offset)
|
||||
.translate(container.styles.margin.top_left)
|
||||
.translate(container.styles.border.spacing.top_left)
|
||||
.translate(-widget.scroll_offset)
|
||||
.translate(container.virtual_region_with_margin.offset)
|
||||
)
|
||||
|
||||
File diff suppressed because one or more lines are too long
28
tests/snapshot_tests/snapshot_apps/scroll_visible_margin.py
Normal file
28
tests/snapshot_tests/snapshot_apps/scroll_visible_margin.py
Normal file
@@ -0,0 +1,28 @@
|
||||
from textual.app import App, ComposeResult
|
||||
from textual.containers import VerticalScroll, Container
|
||||
from textual.widgets import Button
|
||||
|
||||
|
||||
class ScrollVisibleMargin(App):
|
||||
CSS = """
|
||||
Container {
|
||||
height: auto;
|
||||
margin-top: 8;
|
||||
border: solid red;
|
||||
}
|
||||
"""
|
||||
|
||||
def compose(self) -> ComposeResult:
|
||||
with VerticalScroll():
|
||||
with Container():
|
||||
for index in range(1, 51):
|
||||
yield Button(f"Hello, world! ({index})", id=f"b{index}")
|
||||
|
||||
def key_x(self):
|
||||
button_twenty = self.query_one("#b26")
|
||||
button_twenty.scroll_visible()
|
||||
|
||||
|
||||
app = ScrollVisibleMargin()
|
||||
if __name__ == "__main__":
|
||||
app.run()
|
||||
@@ -1300,7 +1300,12 @@ def test_option_list_scrolling_with_multiline_options(snap_compare):
|
||||
# https://github.com/Textualize/textual/issues/4705
|
||||
assert snap_compare(WIDGET_EXAMPLES_DIR / "option_list_tables.py", press=["up"])
|
||||
|
||||
|
||||
def test_bindings_screen_overrides_show(snap_compare):
|
||||
"""Regression test for https://github.com/Textualize/textual/issues/4382"""
|
||||
assert snap_compare(SNAPSHOT_APPS_DIR / "bindings_screen_overrides_show.py")
|
||||
|
||||
|
||||
def test_scroll_visible_with_margin(snap_compare):
|
||||
"""Regression test for https://github.com/Textualize/textual/issues/2181"""
|
||||
assert snap_compare(SNAPSHOT_APPS_DIR / "scroll_visible_margin.py", press=["x"])
|
||||
|
||||
Reference in New Issue
Block a user