From b3d0b00843de9729d9071ed45af7c1fb2a7b19af Mon Sep 17 00:00:00 2001 From: Kevin Lam Date: Tue, 14 Oct 2025 18:35:27 -0500 Subject: [PATCH] Fix selection highlight not updating when selecting a hidden canvasitem lower in the tree dock --- editor/scene/canvas_item_editor_plugin.cpp | 26 ++++++++++++++++++++++ editor/scene/canvas_item_editor_plugin.h | 1 + 2 files changed, 27 insertions(+) diff --git a/editor/scene/canvas_item_editor_plugin.cpp b/editor/scene/canvas_item_editor_plugin.cpp index d1a11ba739..99a658faa2 100644 --- a/editor/scene/canvas_item_editor_plugin.cpp +++ b/editor/scene/canvas_item_editor_plugin.cpp @@ -4492,6 +4492,32 @@ void CanvasItemEditor::_selection_changed() { temp_pivot = Vector2(Math::INF, Math::INF); viewport->queue_redraw(); } + + // Check to redraw to clear anything drawn from visible selections if no selections are visible. + bool has_visible = false; + for (const KeyValue &E : editor_selection->get_selection()) { + CanvasItem *ci = ObjectDB::get_instance(E.key); + if (!ci || !ci->is_visible_in_tree()) { + continue; + } + + Viewport *vp = ci->get_viewport(); + if (vp && !vp->is_visible_subviewport()) { + continue; + } + + CanvasItemEditorSelectedItem *se = editor_selection->get_node_editor_data(ci); + if (se) { + has_visible = true; + break; + } + } + if (had_visible_selection != has_visible) { + if (!has_visible) { + viewport->queue_redraw(); + } + had_visible_selection = has_visible; + } } void CanvasItemEditor::edit(CanvasItem *p_canvas_item) { diff --git a/editor/scene/canvas_item_editor_plugin.h b/editor/scene/canvas_item_editor_plugin.h index 2726b47f41..5ec8a00c67 100644 --- a/editor/scene/canvas_item_editor_plugin.h +++ b/editor/scene/canvas_item_editor_plugin.h @@ -234,6 +234,7 @@ private: real_t resample_delay = 0.3; bool selected_from_canvas = false; + bool had_visible_selection = false; // Defaults are defined in clear(). Point2 grid_offset;