Skip to content

Commit 1e09cba

Browse files
committed
#1976 fix switch camera functionality
1 parent 43c7fa3 commit 1e09cba

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

client/packages/lowcoder/src/comps/comps/fileComp/ImageCaptureModal.tsx

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,8 @@ export const ImageCaptureModal = (props: {
6969
if (props.showModal) {
7070
setImgSrc("");
7171
setErrMessage("");
72+
setVideoConstraints({ facingMode: "environment" });
73+
setDropdownShow(false);
7274
}
7375
}, [props.showModal]);
7476

@@ -119,9 +121,11 @@ export const ImageCaptureModal = (props: {
119121
) : (
120122
<Suspense fallback={<Skeleton />}>
121123
<ReactWebcam
124+
key={JSON.stringify(videoConstraints)}
122125
ref={webcamRef}
123126
onUserMediaError={handleMediaErr}
124127
screenshotFormat="image/jpeg"
128+
videoConstraints={videoConstraints}
125129
/>
126130
</Suspense>
127131
)}
@@ -167,9 +171,10 @@ export const ImageCaptureModal = (props: {
167171
popupRender={() => (
168172
<Menu
169173
items={modeList}
170-
onClick={(value) =>
171-
setVideoConstraints({ ...videoConstraints, deviceId: value.key })
172-
}
174+
onClick={(value) => {
175+
setVideoConstraints({ deviceId: { exact: value.key } });
176+
setDropdownShow(false);
177+
}}
173178
/>
174179
)}
175180
>

0 commit comments

Comments
 (0)