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.