Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Widget.loading scroll-related glitch fixes #3813

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
21 changes: 14 additions & 7 deletions src/textual/widgets/_loading_indicator.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__(
Expand Down Expand Up @@ -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
Expand All @@ -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

Expand Down
Loading