Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 46599c4

Browse files
committed
[Fix]: #1065 duplicates in continuous mode
1 parent 0e5aa97 commit 46599c4

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

‎client/packages/lowcoder/src/comps/comps/buttonComp/scannerComp.tsx‎

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,11 +150,19 @@ const ScannerTmpComp = (function () {
150150
}, [success, showModal]);
151151

152152
const continuousValue = useRef<string[]>([]);
153+
const seenSetRef = useRef<Set<string>>(new Set());
153154

154155
const handleUpdate = (err: any, result: any) => {
155156
if (result) {
156157
if (props.continuous) {
157-
continuousValue.current = [...continuousValue.current, result.text];
158+
const scannedText: string = result.text;
159+
if (props.uniqueData && seenSetRef.current.has(scannedText)) {
160+
return;
161+
}
162+
continuousValue.current = [...continuousValue.current, scannedText];
163+
if (props.uniqueData) {
164+
seenSetRef.current.add(scannedText);
165+
}
158166
const val = props.uniqueData
159167
? [...new Set(continuousValue.current)]
160168
: continuousValue.current;
@@ -205,6 +213,7 @@ const ScannerTmpComp = (function () {
205213
props.onEvent("click");
206214
setShowModal(true);
207215
continuousValue.current = [];
216+
seenSetRef.current = new Set();
208217
}}
209218
>
210219
<span>{props.text}</span>

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /