@@ -3,7 +3,7 @@ import type { ObjectURL } from '@getodk/common/lib/web-compat/url.ts';
3
3
import { createObjectURL , revokeObjectURL } from ' @getodk/common/lib/web-compat/url.ts' ;
4
4
import type { UploadNode } from ' @getodk/xforms-engine' ;
5
5
import Button from ' primevue/button' ;
6
- import { computed , ref , watchEffect } from ' vue' ;
6
+ import { computed , ref , triggerRef , watchEffect } from ' vue' ;
7
7
8
8
export interface UploadImagePreviewProps {
9
9
readonly question: UploadNode ;
@@ -28,6 +28,18 @@ const onPreviewLoad = (event: Event) => {
28
28
const previewImage = event .target as HTMLImageElement ;
29
29
30
30
loadedDimensions .value = previewImage ;
31
+
32
+ /**
33
+ * Ensures `isSmallImage` will be recomputed if `previewImage` has already
34
+ * been assigned to `loadedDimensions.value` by a prior upload.
35
+ *
36
+ * TODO: it would be nice to find (or build?) something equivalent to Solid's
37
+ * {@link https://docs.solidjs.com/reference/basic-reactivity/create-signal#equals | `equals` option} ,
38
+ * which would allow specifying this behavior directly on `loadedDimensions`
39
+ * (and would allow customizing it e.g. to recompute specifically if an
40
+ * `HTMLImageElement` is assigned).
41
+ */
42
+ triggerRef (loadedDimensions );
31
43
};
32
44
33
45
const SMALL_IMAGE_SIZE = 300 ;
0 commit comments