diff --git a/tab_timeline_ng.py b/tab_timeline_ng.py index 68aaca2..5b009f2 100644 --- a/tab_timeline_ng.py +++ b/tab_timeline_ng.py @@ -427,62 +427,58 @@ def _render_graphviz(dot_source: str, selected_node_id: str | None = None): src = graphviz.Source(dot_source) svg = src.pipe(format='svg').decode('utf-8') - # (a) Keep SVG at natural size, let scroll container handle overflow - html_el = ui.html( - f'
' - f'{svg}
' - ) - - # (b) + (c) JS click handlers + visual feedback - # Use NiceGUI's element ID (getElement) for reliable DOM lookup sel_escaped = selected_node_id.replace("'", "\\'") if selected_node_id else '' - ui.run_javascript(f''' - requestAnimationFrame(() => {{ - const wrapper = getElement({html_el.id}); - if (!wrapper) return; - const container = wrapper.querySelector('div'); + + # Embed CSS + JS inline so there are no timing/lookup issues + inline_script = ''' + + + ''' % sel_escaped + + ui.html( + f'
' + f'{svg}{inline_script}
' + ) except ImportError: ui.label('Install graphviz Python package for graph rendering.').classes('text-warning') ui.code(dot_source).classes('w-full')