Commit 8ec18fe
committed
fix(files): reserve embedded-image space on direct file-view loads
An embedded image in a markdown file reshifted on every open: it loaded ~2.3s in with
no reserved box and shoved everything below it down (CLS ~0.17).
The intrinsic dimensions ARE stored server-side, but the image node view never read them
at render. useWorkspaceImageDimensionsAdapter read the active files list via
queryClient.getQueryData — non-reactively — so on a cold file-view load it returned null
at first render and, because the adapter identity was stable, never re-checked when the
list later resolved.
Read the list via a reactive useWorkspaceFiles subscription instead: the adapter
re-identifies when the list arrives, re-running the image node view's memoized dimension
read so it reserves the box from the stored dimensions before the (slower) image download
finishes. The query key is shared, so it dedupes with surrounding views. Gate it behind
`enabled` (driven by the absence of a caller-supplied contentSource) so the public share
page — which passes a share token as workspaceId — doesn't fire a 404.
Verified in a CLS harness: dims present -> 0 shift; dims absent -> 0.20.1 parent 9b80fdd commit 8ec18fe
2 files changed
Lines changed: 25 additions & 4 deletions
File tree
- apps/sim
- app/workspace/[workspaceId]/files/components/file-viewer
- hooks/queries
Lines changed: 6 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
131 | 131 | | |
132 | 132 | | |
133 | 133 | | |
134 | | - | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
135 | 140 | | |
136 | 141 | | |
137 | 142 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
150 | 150 | | |
151 | 151 | | |
152 | 152 | | |
153 | | - | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
154 | 157 | | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
155 | 171 | | |
156 | 172 | | |
157 | 173 | | |
158 | | - | |
| 174 | + | |
159 | 175 | | |
160 | 176 | | |
161 | 177 | | |
| |||
194 | 210 | | |
195 | 211 | | |
196 | 212 | | |
197 | | - | |
| 213 | + | |
198 | 214 | | |
199 | 215 | | |
200 | 216 | | |
| |||
0 commit comments