From 89ff582c3dd408f0ccd1df113b543eafb84dc457 Mon Sep 17 00:00:00 2001 From: Isaiah Odhner Date: Sat, 3 Jun 2023 15:32:10 -0400 Subject: [PATCH] Remove highlight boxes associated with an old DOM node --- src/textual_paint/inspector.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/textual_paint/inspector.py b/src/textual_paint/inspector.py index 2265309..7145249 100644 --- a/src/textual_paint/inspector.py +++ b/src/textual_paint/inspector.py @@ -838,7 +838,9 @@ class Inspector(Container): for index, region in enumerate(regions): show_box(f"clipped:{index}", region, "aquamarine") # remove unused boxes - for name, box in list(self._highlight_boxes[dom_node].items()): - if box not in used_boxes: - box.remove() - del self._highlight_boxes[dom_node][name] \ No newline at end of file + # including boxes associated with an old dom_node + for dom_node, boxes in list(self._highlight_boxes.items()): + for name, box in list(boxes.items()): + if box not in used_boxes: + box.remove() + del self._highlight_boxes[dom_node][name] \ No newline at end of file