diff --git a/CHANGELOG.md b/CHANGELOG.md index 0b4c2ef6ca..d54aa97a78 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/). - Fixed `DataTable.update_cell` not raising an error with an invalid column key https://github.com/Textualize/textual/issues/3335 - Fixed `Input` showing suggestions when not focused https://github.com/Textualize/textual/pull/3808 +- Fixed `Widget.loading` overlay being affected by scroll position and scrollbar gutter https://github.com/Textualize/textual/pull/3813 ### Removed diff --git a/src/textual/widgets/_loading_indicator.py b/src/textual/widgets/_loading_indicator.py index a61a476e8d..fb5ef9be1c 100644 --- a/src/textual/widgets/_loading_indicator.py +++ b/src/textual/widgets/_loading_indicator.py @@ -26,20 +26,22 @@ class LoadingIndicator(Widget): color: $accent; } LoadingIndicator.-overlay { + dock: top; layer: _loading; background: $boost; } """ _widget_state: ClassVar[ - WeakKeyDictionary[Widget, tuple[bool, str, str]] + WeakKeyDictionary[Widget, tuple[bool, str, str, str]] ] = WeakKeyDictionary() - """Widget state that must be restore after loading. - + """Widget state that must be restored after loading. + The tuples indicate the original values of the: - widget disabled state; - - widget style overflow_x rule; and - - widget style overflow_y rule. + - widget style overflow_x rule; + - widget style overflow_y rule; and + - widget style scrollbar_gutter rule. """ def __init__( @@ -79,7 +81,9 @@ def apply(self, widget: Widget) -> AwaitMount: widget.disabled, widget.styles.overflow_x, widget.styles.overflow_y, + widget.styles.scrollbar_gutter, ) + widget.styles.scrollbar_gutter = "auto" widget.styles.overflow_x = "hidden" widget.styles.overflow_y = "hidden" widget.disabled = True @@ -106,10 +110,13 @@ async def null() -> None: await_remove = null() if widget in cls._widget_state: - disabled, overflow_x, overflow_y = cls._widget_state[widget] - widget.disabled = disabled + disabled, overflow_x, overflow_y, scrollbar_gutter = cls._widget_state[ + widget + ] + widget.styles.scrollbar_gutter = scrollbar_gutter widget.styles.overflow_x = overflow_x widget.styles.overflow_y = overflow_y + widget.disabled = disabled return await_remove