Skip to content

fix(diagram): mermaid zoom buttons dead after cached tab restore; Ctrl+= zooms in#3

Open
matthew-zb wants to merge 1 commit into
masterfrom
fix/diagram-zoom-cached-tabs
Open

fix(diagram): mermaid zoom buttons dead after cached tab restore; Ctrl+= zooms in#3
matthew-zb wants to merge 1 commit into
masterfrom
fix/diagram-zoom-cached-tabs

Conversation

@matthew-zb

Copy link
Copy Markdown
Collaborator

Summary

Fixes the intermittent "diagram zoom does nothing" report. Two root causes:

1. Zoom buttons lose their click listeners after a cached tab restore

Switching back to a previously rendered tab restores the preview via preview.innerHTML = tab.renderedHTML (src/tabs.js). This recreates the mermaid zoom buttons from serialized HTML — markup survives, event listeners don't — leaving visually intact but dead buttons. Fresh opens and F5 re-render from scratch, which is why the bug only reproduced "sometimes."

Fix: replace per-button listeners with a single delegated click listener on #preview, so buttons work no matter how the DOM was (re)created.

2. Ctrl+= was mapped to zoom reset instead of zoom in

On most keyboards "Ctrl and the + key" without Shift produces key === '=', which was mapped to reset — so keyboard zoom-in silently never zoomed. Now follows browser convention: Ctrl++ / Ctrl+= zoom in, Ctrl+0 resets. The toolbar tooltips already documented this mapping ("Zoom In (Ctrl+=)", "리셋 (Ctrl+0)"); this aligns the code with them.

Also updates the About dialog shortcut table (Ctrl + + / = → Zoom In, Ctrl + 0 → Reset Zoom) and adds a Reset Zoom (Ctrl+0) tooltip to the zoom level indicator.

Test plan

  • Open a file with a mermaid diagram, open a second tab, switch back → click the diagram expand button → overlay opens
  • In the overlay and in the main view: Ctrl+= zooms in, Ctrl++ zooms in, Ctrl+0 resets
  • About dialog shows the updated shortcut table

🤖 Generated with Claude Code

…s in

Two fixes for 'diagram zoom sometimes does nothing':

- Tab switch restores preview via innerHTML from the render cache,
  which recreates the mermaid zoom buttons without their click
  listeners. Move click handling to a single delegated listener on
  #preview so buttons work regardless of how the DOM was (re)created.

- Ctrl+= (plus key without Shift) was mapped to zoom reset, so
  keyboard zoom-in silently never zoomed. Follow browser convention:
  Ctrl+= / Ctrl++ zoom in, Ctrl+0 resets. Toolbar tooltips already
  documented this mapping. Update About dialog shortcut table and add
  a reset tooltip to the zoom level indicator.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@gemini-code-assist

Copy link
Copy Markdown

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants