From c7c9a6ec67fabaca2e73256703e1d9be25e8975a Mon Sep 17 00:00:00 2001 From: Will McGugan Date: Thu, 23 May 2024 17:02:11 +0100 Subject: [PATCH] fix check --- src/textual/widget.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/textual/widget.py b/src/textual/widget.py index 51a892edba..3c474f3ce2 100644 --- a/src/textual/widget.py +++ b/src/textual/widget.py @@ -1123,10 +1123,11 @@ async def recompose(self) -> None: Recomposing will remove children and call `self.compose` again to remount. """ - async with self.batch(): - await self.query("*").exclude(".-textual-system").remove() - if self._is_linked_to_app: - await self.mount_all(compose(self)) + if self._parent is not None: + async with self.batch(): + await self.query("*").exclude(".-textual-system").remove() + if self._is_linked_to_app: + await self.mount_all(compose(self)) def _post_register(self, app: App) -> None: """Called when the instance is registered.