[UI] Handle duplicate cameras (#13167) (#13171)

Fixes https://github.com/inventree/InvenTree/issues/13164

(cherry picked from commit 2310b54e26)

Co-authored-by: Oliver <oliver.henry.walters@gmail.com>
This commit is contained in:
github-actions[bot]andOliver authored and GitHub committed 2026-11-03 13:16:21 +11:00
1 parent 7f3171451c
commit 5618ba7907
1 file changed
+10 -2
@@ -112,8 +112,16 @@ export default function BarcodeCameraInput({
legacyScannerRef.current = new Html5Qrcode('reader');
}
Html5Qrcode.getCameras().then((devices) => {
if (devices?.length) {
Html5Qrcode.getCameras().then((cameraList) => {
// Some browsers (e.g. Firefox on Linux) can report the same physical
// camera more than once with an identical deviceId. Mantine's Select
// throws on duplicate option values, so de-duplicate by id here.
const devices = (cameraList ?? []).filter(
(device, index, list) =>
list.findIndex((other) => other.id === device.id) === index
);
if (devices.length) {
setCameras(devices);
// Auto-select a camera so the play button is immediately usable,