From 0d1bf9958f35cb4c7f1abd08989f39066562cb93 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?C=C3=A9line=20S=C3=A8be?=
<87119259+CelineSebe@users.noreply.github.com>
Date: Fri, 25 Oct 2024 16:49:17 +0200
Subject: [PATCH] [frontend] Fix potential duplicate warning messages (#8180)
---
.../src/components/TextField.jsx | 20 +++++++++----------
.../StixDomainObjectDetectDuplicate.jsx | 6 +++---
2 files changed, 13 insertions(+), 13 deletions(-)
diff --git a/opencti-platform/opencti-front/src/components/TextField.jsx b/opencti-platform/opencti-front/src/components/TextField.jsx
index 8846063a332b..753b635ee36f 100644
--- a/opencti-platform/opencti-front/src/components/TextField.jsx
+++ b/opencti-platform/opencti-front/src/components/TextField.jsx
@@ -50,16 +50,16 @@ const TextField = (props) => {
error={!isNil(meta.error)}
helperText={
// eslint-disable-next-line no-nested-ternary
- (detectDuplicate && meta.value?.length > 2) && (isNil(meta.error) || !meta.touched) ? (
-
- ) : meta.error ? (
- meta.error
- ) : (
- props.helperText
- )
+ detectDuplicate && (isNil(meta.error) || !meta.touched) ? (
+
+ ) : meta.error ? (
+ meta.error
+ ) : (
+ props.helperText
+ )
}
onChange={internalOnChange}
onFocus={internalOnFocus}
diff --git a/opencti-platform/opencti-front/src/private/components/common/stix_domain_objects/StixDomainObjectDetectDuplicate.jsx b/opencti-platform/opencti-front/src/private/components/common/stix_domain_objects/StixDomainObjectDetectDuplicate.jsx
index 110b4a3cd6f3..a6afb3a2002f 100644
--- a/opencti-platform/opencti-front/src/private/components/common/stix_domain_objects/StixDomainObjectDetectDuplicate.jsx
+++ b/opencti-platform/opencti-front/src/private/components/common/stix_domain_objects/StixDomainObjectDetectDuplicate.jsx
@@ -50,7 +50,7 @@ class StixDomainObjectDetectDuplicate extends Component {
componentDidUpdate(prevProps) {
if (this.props.value !== prevProps.value) {
- if (this.props.value.length > 2) {
+ if (this.props.value.length >= 2) {
fetchQuery(stixDomainObjectsLinesSearchQuery, {
types: this.props.types,
search: `"${this.props.value}"`,
@@ -82,7 +82,7 @@ class StixDomainObjectDetectDuplicate extends Component {
render() {
const { potentialDuplicates } = this.state;
- const { t, classes } = this.props;
+ const { t, classes, value } = this.props;
return (
- {potentialDuplicates.length === 0
+ {value && potentialDuplicates.length === 0
? t('No potential duplicate entities has been found.')
: ''}
{potentialDuplicates.length === 1 ? (