diff --git a/docs/guide/widgets.md b/docs/guide/widgets.md index f4c2c8b1ea..863e2208d6 100644 --- a/docs/guide/widgets.md +++ b/docs/guide/widgets.md @@ -296,7 +296,7 @@ Add a rule to your CSS that targets `Tooltip`. Here's an example: ## Loading indicator -Widgets have a [`loading`][textual.widget.Widget.loading] reactive which when set to `True` will temporarily replace your widget with a [LoadingIndicator](../widgets/loading_indicator.md). +Widgets have a [`loading`][textual.widget.Widget.loading] reactive which when set to `True` will temporarily replace your widget with a [`LoadingIndicator`](../widgets/loading_indicator.md). You can use this to indicate to the user that the app is currently working on getting data, and there will be content when that data is available. Let's look at an example of this. diff --git a/src/textual/widget.py b/src/textual/widget.py index 381d2dc227..0fb94ad2e1 100644 --- a/src/textual/widget.py +++ b/src/textual/widget.py @@ -506,7 +506,7 @@ def set_loading(self, loading: bool) -> Awaitable: A widget in a loading state will display a LoadingIndicator that obscures the widget. Args: - loading: `True` to put the widget in to a loading state, or `False` to reset the loading state. + loading: `True` to put the widget into a loading state, or `False` to reset the loading state. Returns: An optional awaitable. diff --git a/tests/test_widget.py b/tests/test_widget.py index ad5e3a8ed6..4b0058aafe 100644 --- a/tests/test_widget.py +++ b/tests/test_widget.py @@ -367,11 +367,19 @@ def compose(self) -> ComposeResult: label = app.query_one(Label) assert label.loading == False assert len(label.query(LoadingIndicator)) == 0 + label.loading = True await pilot.pause() assert len(label.query(LoadingIndicator)) == 1 + label.loading = True # Setting to same value is a null-op + await pilot.pause() + assert len(label.query(LoadingIndicator)) == 1 + label.loading = False await pilot.pause() assert len(label.query(LoadingIndicator)) == 0 + label.loading = False # Setting to same value is a null-op + await pilot.pause() + assert len(label.query(LoadingIndicator)) == 0