From 5c30568cd709ed964316d7f12b229a09ef17b729 Mon Sep 17 00:00:00 2001 From: Rodja Trappe Date: Fri, 30 Aug 2024 07:06:41 +0200 Subject: [PATCH] only remove elements if they are still there --- nicegui/client.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/nicegui/client.py b/nicegui/client.py index 8b128ea95..453f100e9 100644 --- a/nicegui/client.py +++ b/nicegui/client.py @@ -311,7 +311,8 @@ def remove_elements(self, elements: Iterable[Element]) -> None: element._handle_delete() # pylint: disable=protected-access element._deleted = True # pylint: disable=protected-access self.outbox.enqueue_delete(element) - del self.elements[element.id] + if element.id in self.elements: + del self.elements[element.id] def remove_all_elements(self) -> None: """Remove all elements from the client."""