Skip to content

Commit fc5ec54

Browse files
authored
fix: Merge pull request #431 from CedricProfessionnel/KillClassDuplicate
Class (Labels) duplicate impossible
2 parents 5d22050 + 2e098db commit fc5ec54

File tree

1 file changed

+11
-4
lines changed
  • src/components/ConfigureImageClassification

1 file changed

+11
-4
lines changed

src/components/ConfigureImageClassification/index.js

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@ export default ({ iface, onChange }) => {
3232
() => ({
3333
multiple: iface.multiple ? iface.multiple : false,
3434
labels:
35-
(iface.labels || []).map((a) =>
36-
typeof a === "string" ? { id: a, description: a } : a
37-
) || [],
35+
(iface.labels || []).map((a) => {
36+
return typeof a === "string" ? { id: a, description: a } : a
37+
}) || [],
3838
}),
3939
[iface.labels, iface.multiple]
4040
)
@@ -43,7 +43,14 @@ export default ({ iface, onChange }) => {
4343
noActions
4444
variant="flat"
4545
defaultAnswers={defaultAnswers}
46-
onQuestionChange={(questionId, newValue, answers) => {
46+
onQuestionChange={(questionId, newValue) => {
47+
var arrayId = []
48+
if (Array.isArray(newValue))
49+
newValue = newValue.filter((json) => {
50+
if (arrayId.includes(json.id)) return false
51+
arrayId.push(json.id)
52+
return true
53+
})
4754
onChange(setIn(iface, [questionId], newValue))
4855
}}
4956
form={form}

0 commit comments

Comments
 (0)