Skip to content

Commit

Permalink
Remove any scrollbar gutter while Widget.loading is True
Browse files Browse the repository at this point in the history
  • Loading branch information
davep committed Dec 5, 2023
1 parent 06beaa5 commit 98cf423
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions src/textual/widgets/_loading_indicator.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,15 @@ class LoadingIndicator(Widget):
"""

_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.
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 @@ -80,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 @@ -107,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

0 comments on commit 98cf423

Please sign in to comment.