From 35bb4104eb9e31ec3e398f3b3fedc7ff714e4f9b Mon Sep 17 00:00:00 2001 From: aprudhomme-coveo <132079077+aprudhomme-coveo@users.noreply.github.com> Date: Thu, 10 Aug 2023 09:12:45 -0400 Subject: [PATCH] fix(atomic,headless): add maximum value of 10 for 'desiredCount' (#3089) https://coveord.atlassian.net/browse/KIT-2635 --- .../atomic-automatic-facet-generator.tsx | 4 +--- .../automatic-facet-set/automatic-facet-set-actions.ts | 9 ++++++++- .../automatic-facet-set/automatic-facet-set-constants.ts | 2 ++ 3 files changed, 11 insertions(+), 4 deletions(-) create mode 100644 packages/headless/src/features/facets/automatic-facet-set/automatic-facet-set-constants.ts diff --git a/packages/atomic/src/components/search/facets/atomic-automatic-facet-generator/atomic-automatic-facet-generator.tsx b/packages/atomic/src/components/search/facets/atomic-automatic-facet-generator/atomic-automatic-facet-generator.tsx index cbbfebba6e8..bef67be3667 100644 --- a/packages/atomic/src/components/search/facets/atomic-automatic-facet-generator/atomic-automatic-facet-generator.tsx +++ b/packages/atomic/src/components/search/facets/atomic-automatic-facet-generator/atomic-automatic-facet-generator.tsx @@ -1,4 +1,4 @@ -import {BooleanValue, NumberValue, Schema} from '@coveo/bueno'; +import {BooleanValue, Schema} from '@coveo/bueno'; import { AutomaticFacetGenerator, AutomaticFacetGeneratorState, @@ -74,10 +74,8 @@ export class AtomicAutomaticFacetGenerator implements InitializableComponent { private validateProps() { new Schema({ - desiredCount: new NumberValue({min: 1, required: true}), areCollapsed: new BooleanValue({default: true, required: false}), }).validate({ - desiredCount: this.desiredCount, areCollapsed: this.areCollapsed, }); } diff --git a/packages/headless/src/features/facets/automatic-facet-set/automatic-facet-set-actions.ts b/packages/headless/src/features/facets/automatic-facet-set/automatic-facet-set-actions.ts index 21f19cff970..e66195249dd 100644 --- a/packages/headless/src/features/facets/automatic-facet-set/automatic-facet-set-actions.ts +++ b/packages/headless/src/features/facets/automatic-facet-set/automatic-facet-set-actions.ts @@ -7,6 +7,10 @@ import { import {facetValueDefinition} from '../facet-set/facet-set-validate-payload'; import {FacetValue} from '../facet-set/interfaces/response'; import {facetIdDefinition} from '../generic/facet-actions-validation'; +import { + DESIRED_COUNT_MAXIMUM, + DESIRED_COUNT_MINIMUM, +} from './automatic-facet-set-constants'; export interface ToggleSelectAutomaticFacetValueActionCreatorPayload { /** @@ -20,7 +24,10 @@ export interface ToggleSelectAutomaticFacetValueActionCreatorPayload { selection: FacetValue; } -const desiredCountDefinition = new NumberValue({min: 1}); +const desiredCountDefinition = new NumberValue({ + min: DESIRED_COUNT_MINIMUM, + max: DESIRED_COUNT_MAXIMUM, +}); export const setDesiredCount = createAction( 'automaticFacet/setDesiredCount', (payload: number) => validatePayload(payload, desiredCountDefinition) diff --git a/packages/headless/src/features/facets/automatic-facet-set/automatic-facet-set-constants.ts b/packages/headless/src/features/facets/automatic-facet-set/automatic-facet-set-constants.ts new file mode 100644 index 00000000000..789e89960c3 --- /dev/null +++ b/packages/headless/src/features/facets/automatic-facet-set/automatic-facet-set-constants.ts @@ -0,0 +1,2 @@ +export const DESIRED_COUNT_MAXIMUM = 10; +export const DESIRED_COUNT_MINIMUM = 1;