-
Notifications
You must be signed in to change notification settings - Fork 38.9k
SVG without set width or height can't be zoomed #240638
Copy link
Copy link
Closed
Labels
bugIssue identified by VS Code Team member as probable bugIssue identified by VS Code Team member as probable bughelp wantedIssues identified as good community contribution opportunitiesIssues identified as good community contribution opportunitiesinsiders-releasedPatch has been released in VS Code InsidersPatch has been released in VS Code Insiders
Milestone
Description
Type: Bug
If you make an SVG like this:
cat <<EOF >test.svg
<svg viewBox="0 0 100 100" xmlns="http://www.w3.org/2000/svg">
<g>
<rect x="10" y="10" width="30" height="30" />
</g>
</svg>
EOF
then when you try to zoom the SVG in the preview it zooms the background (you can see the checkerboard getting bigger and smaller) but not the foreground. Adding either a fixed width or a fixed height (that is, not a percentage) to the svg tag allows the SVG to be zoomed.
This came up for me because the mermaid CLI outputs SVGs with width="100%" and no height set. To repro that:
cat <<EOF >test.mmd
graph LR
A --> B
EOF
npx @mermaid-js/mermaid-cli -i test.mmd -o test.svg
then open test.svg and note that it can't be zoomed. I am able to zoom it if I open it in a web browser, tested in both Chrome and Safari on a Mac.
VS Code version: Code 1.97.0 (Universal) (33fc5a9, 2025-02-04T22:41:26.688Z)
OS version: Darwin arm64 24.3.0
Modes:
Remote OS version: Linux x64 6.8.0-1021-aws
System Info
| Item | Value |
|---|---|
| CPUs | Apple M2 (8 x 2400) |
| GPU Status | 2d_canvas: enabled canvas_oop_rasterization: enabled_on direct_rendering_display_compositor: disabled_off_ok gpu_compositing: enabled multiple_raster_threads: enabled_on opengl: enabled_on rasterization: enabled raw_draw: disabled_off_ok skia_graphite: disabled_off video_decode: enabled video_encode: enabled webgl: enabled webgl2: enabled webgpu: enabled webnn: disabled_off |
| Load (avg) | 4, 4, 4 |
| Memory (System) | 24.00GB (0.09GB free) |
| Process Argv | --crash-reporter-id ce7ae8b4-58c3-43d1-bccf-8fd59a2f2bb1 |
| Screen Reader | no |
| VM | 0% |
| Item | Value |
|---|---|
| Remote | SSH: redacted |
| OS | Linux x64 6.8.0-1021-aws |
| CPUs | AMD EPYC-Milan Processor (30 x 0) |
| Memory (System) | 50.98GB (36.15GB free) |
| VM | 0% |
A/B Experiments
vsliv368:30146709
vspor879:30202332
vspor708:30202333
vspor363:30204092
vscod805cf:30301675
binariesv615:30325510
py29gd2263:31024239
c4g48928:30535728
azure-dev_surveyone:30548225
2i9eh265:30646982
962ge761:30959799
h48ei257:31000450
pythontbext0:30879054
cppperfnew:31000557
dwnewjupytercf:31046870
nativerepl1:31139838
pythonrstrctxt:31112756
nativeloc1:31192215
iacca1:31171482
5fd0e150:31155592
dwcopilot:31170013
stablechunks:31184530
6074i472:31201624
dwoutputs:31233690
hdaa2157:31222309
copilot_t_ci:31222730
jda6j935:31233686
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugIssue identified by VS Code Team member as probable bugIssue identified by VS Code Team member as probable bughelp wantedIssues identified as good community contribution opportunitiesIssues identified as good community contribution opportunitiesinsiders-releasedPatch has been released in VS Code InsidersPatch has been released in VS Code Insiders