diff --git a/frontend/src/component/common/NewConstraintAccordion/ConstraintAccordionEdit/ConstraintAccordionEditBody/RestrictiveLegalValues/RestrictiveLegalValues.tsx b/frontend/src/component/common/NewConstraintAccordion/ConstraintAccordionEdit/ConstraintAccordionEditBody/RestrictiveLegalValues/RestrictiveLegalValues.tsx index 3d164a7f8b..3893efc8cc 100644 --- a/frontend/src/component/common/NewConstraintAccordion/ConstraintAccordionEdit/ConstraintAccordionEditBody/RestrictiveLegalValues/RestrictiveLegalValues.tsx +++ b/frontend/src/component/common/NewConstraintAccordion/ConstraintAccordionEdit/ConstraintAccordionEditBody/RestrictiveLegalValues/RestrictiveLegalValues.tsx @@ -158,10 +158,12 @@ export const RestrictiveLegalValues = ({ }; const handleSearchKeyDown = (event: React.KeyboardEvent) => { - if (event.key === 'Enter' && filteredValues.length > 0) { + if (event.key === 'Enter') { event.preventDefault(); - const firstValue = filteredValues[0].value; - onChange(firstValue); + if (filteredValues.length > 0) { + const firstValue = filteredValues[0].value; + onChange(firstValue); + } } }; diff --git a/frontend/src/component/feature/FeatureStrategy/FeatureStrategyConstraints/EditableConstraint.tsx b/frontend/src/component/feature/FeatureStrategy/FeatureStrategyConstraints/EditableConstraint.tsx index c69ca5f1dd..fa19e6756d 100644 --- a/frontend/src/component/feature/FeatureStrategy/FeatureStrategyConstraints/EditableConstraint.tsx +++ b/frontend/src/component/feature/FeatureStrategy/FeatureStrategyConstraints/EditableConstraint.tsx @@ -1,21 +1,6 @@ import { IconButton, styled } from '@mui/material'; import GeneralSelect from 'component/common/GeneralSelect/GeneralSelect'; -import { DateSingleValue } from 'component/common/NewConstraintAccordion/ConstraintAccordionEdit/ConstraintAccordionEditBody/DateSingleValue/DateSingleValue'; -import { FreeTextInput } from 'component/common/NewConstraintAccordion/ConstraintAccordionEdit/ConstraintAccordionEditBody/FreeTextInput/FreeTextInput'; -import { SingleLegalValue } from 'component/common/NewConstraintAccordion/ConstraintAccordionEdit/ConstraintAccordionEditBody/SingleLegalValue/SingleLegalValue'; -import { SingleValue } from 'component/common/NewConstraintAccordion/ConstraintAccordionEdit/ConstraintAccordionEditBody/SingleValue/SingleValue'; -import { - DATE_OPERATORS_SINGLE_VALUE, - IN_OPERATORS_FREETEXT, - IN_OPERATORS_LEGAL_VALUES, - NUM_OPERATORS_LEGAL_VALUES, - NUM_OPERATORS_SINGLE_VALUE, - SEMVER_OPERATORS_LEGAL_VALUES, - SEMVER_OPERATORS_SINGLE_VALUE, - STRING_OPERATORS_FREETEXT, - STRING_OPERATORS_LEGAL_VALUES, - type Input, -} from 'component/common/NewConstraintAccordion/ConstraintAccordionEdit/ConstraintAccordionEditBody/useConstraintInput/useConstraintInput'; +import type { Input } from 'component/common/NewConstraintAccordion/ConstraintAccordionEdit/ConstraintAccordionEditBody/useConstraintInput/useConstraintInput'; import { DATE_AFTER, dateOperators, @@ -43,7 +28,7 @@ import { ReactComponent as CaseSensitiveIcon } from 'assets/icons/case-sensitive import { ReactComponent as CaseInsensitiveIcon } from 'assets/icons/case-insensitive.svg'; import { ScreenReaderOnly } from 'component/common/ScreenReaderOnly/ScreenReaderOnly'; import { AddValuesWidget } from './AddValuesWidget'; -import { LegalValuesSelector } from './LegalValuesSelector'; +import { ResolveInput } from 'component/common/NewConstraintAccordion/ConstraintAccordionEdit/ConstraintAccordionEditBody/ResolveInput/ResolveInput'; const Container = styled('article')(({ theme }) => ({ '--padding': theme.spacing(2), @@ -149,6 +134,7 @@ const OPERATORS_WITH_ADD_VALUES_WIDGET = [ ]; type Props = { + constraint: IConstraint; localConstraint: IConstraint; setContextName: (contextName: string) => void; setOperator: (operator: Operator) => void; @@ -172,6 +158,7 @@ type Props = { }; export const EditableConstraint: FC = ({ constraintChanges, + constraint, localConstraint, setLocalConstraint, setContextName, @@ -255,116 +242,6 @@ export const EditableConstraint: FC = ({ } }; - const Input = () => { - switch (input) { - case IN_OPERATORS_LEGAL_VALUES: - case STRING_OPERATORS_LEGAL_VALUES: - return ( - - ); - case NUM_OPERATORS_LEGAL_VALUES: - return ( - <> - Number(legalValue.value), - ) || [] - } - error={error} - setError={setError} - /> - - ); - case SEMVER_OPERATORS_LEGAL_VALUES: - return ( - <> - - - ); - case DATE_OPERATORS_SINGLE_VALUE: - return ( - - ); - case IN_OPERATORS_FREETEXT: - return ( - - ); - case STRING_OPERATORS_FREETEXT: - return ( - <> - - - ); - case NUM_OPERATORS_SINGLE_VALUE: - return ( - - ); - case SEMVER_OPERATORS_SINGLE_VALUE: - return ( - - ); - } - }; - return ( @@ -454,7 +331,19 @@ export const EditableConstraint: FC = ({ - + ); diff --git a/frontend/src/component/feature/FeatureStrategy/FeatureStrategyConstraints/EditableConstraintWrapper.tsx b/frontend/src/component/feature/FeatureStrategy/FeatureStrategyConstraints/EditableConstraintWrapper.tsx index c4379c81d1..6dd2873b81 100644 --- a/frontend/src/component/feature/FeatureStrategy/FeatureStrategyConstraints/EditableConstraintWrapper.tsx +++ b/frontend/src/component/feature/FeatureStrategy/FeatureStrategyConstraints/EditableConstraintWrapper.tsx @@ -206,6 +206,7 @@ export const EditableConstraintWrapper = ({ error={error} contextDefinition={contextDefinition} removeValue={removeValue} + constraint={constraint} /> ); }; diff --git a/frontend/src/component/feature/FeatureStrategy/FeatureStrategyConstraints/LegalValuesSelector.tsx b/frontend/src/component/feature/FeatureStrategy/FeatureStrategyConstraints/LegalValuesSelector.tsx index 8170595484..13a9580743 100644 --- a/frontend/src/component/feature/FeatureStrategy/FeatureStrategyConstraints/LegalValuesSelector.tsx +++ b/frontend/src/component/feature/FeatureStrategy/FeatureStrategyConstraints/LegalValuesSelector.tsx @@ -133,9 +133,12 @@ export const LegalValuesSelector = ({ }; const handleSearchKeyDown = (event: React.KeyboardEvent) => { - if (event.key === 'Enter' && filteredValues.length > 0) { - const firstValue = filteredValues[0].value; - onChange(firstValue); + if (event.key === 'Enter') { + event.preventDefault(); + if (filteredValues.length > 0) { + const firstValue = filteredValues[0].value; + onChange(firstValue); + } } };