The README badges in Zed looked like links but weren't
By Warya Wayne ·
Open a README in Zed's markdown preview. The build badge at the top renders correctly. Click it. Nothing happens.
Linked images — [](https://destination), the shape every badge in every README uses — rendered properly but weren't interactive. No pointer cursor, no click, no "Copy Link" in the context menu. They looked like links and behaved like decoration.
Why it broke
The renderer handled <a> tags and it handled <img> tags. What it didn't handle was an <img> nested inside an <a>. The image drew itself and the surrounding link never got a chance to make it interactive.
The fix
Detect the nesting during render. When a linked image is found, the wrapper div gets cursor_pointer and an on_click handler that opens the URL — or delegates to the on_url_click callback when one is set. The wrapper also captures right-clicks so "Copy Link" shows up in the context menu.
Two details made this more than a one-liner:
The callback had to become cloneable. on_url_click was a Box<dyn Fn>, which one handler can own. Now multiple handlers need it, so it became an Rc<dyn Fn>.
Broken images opened the URL twice. When an image fails to load, a fallback element renders in its place — and that fallback had its own click handler. Clicking it fired the fallback's handler and bubbled up to the wrapper's, opening the destination twice. The fix was cx.stop_propagation() in the fallback.
That second bug is the kind you only find by deliberately breaking things. A badge whose image 404s is not an edge case in the wild — it's Tuesday.
The whole feature is gated behind !self.style.prevent_mouse_interaction, so contexts that deliberately disable interaction keep working as before.
Testing
cargo test -p markdown — 95 tests passing, plus manual verification that badges open correctly and right-click offers "Copy Link".
Merged as zed-industries/zed#59525.