From 60c022828d77c8274147a5618d7340411eda7a1e Mon Sep 17 00:00:00 2001 From: Arda Aydin Date: Sat, 12 Sep 2026 22:15:48 +0300 Subject: [PATCH] Fix live-mode link navigation not selecting the target link In live mode the DOM is rebuilt from the device when switching sheets, creating new element objects. The pending link from the old tree could not be found by identity in canvas_link_map. Re-resolve it by from/to attributes after the rebuild so the selection matches. Co-Authored-By: Claude Opus 4.6 --- app_state.py | 2 +- main.py | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/app_state.py b/app_state.py index 4ae77f3..942dc37 100644 --- a/app_state.py +++ b/app_state.py @@ -8,7 +8,7 @@ so later rebinding would only ever be seen by the module that did it. import configparser import os -VERSION = "0.0.0.094" +VERSION = "0.0.0.095" PROPERTIES_FILE = os.path.join(os.path.dirname(os.path.abspath(__file__)), "editor.properties") DEFAULT_GRID_SIZE = 10 DEFAULT_ADD_TIMESTAMP = True diff --git a/main.py b/main.py index 9e53b9c..623bf2b 100644 --- a/main.py +++ b/main.py @@ -637,6 +637,18 @@ def on_tree_select(event): except Exception: import traceback; traceback.print_exc() + # The DOM rebuild replaced every element object, so a pending link from the + # old tree can no longer be found by identity. Re-resolve it by from/to. + if pending_link is not None: + old_from = pending_link.get("from", "") + old_to = pending_link.get("to", "") + links_container = app_state.xml_root_element.find("links") if app_state.xml_root_element is not None else None + if links_container is not None: + for lnk in links_container: + if lnk.get("from") == old_from and lnk.get("to") == old_to: + pending_link = lnk + break + if element is not None: components_to_render = [child for child in element if child.tag == "comp"] elif tree.exists(selected_id):