diff --git a/packages/core/src/context/experiment/experiment-reducers.ts b/packages/core/src/context/experiment/experiment-reducers.ts index 08a5c3fb..755b59a1 100644 --- a/packages/core/src/context/experiment/experiment-reducers.ts +++ b/packages/core/src/context/experiment/experiment-reducers.ts @@ -187,13 +187,12 @@ export const experimentReducer = produce( break case 'updateSuggestionCount': { const payloadVal = Number(action.payload.suggestionCount) - const maxSuggestionCount = action.payload.maxSuggestionCount - let actualVal = payloadVal - if (maxSuggestionCount !== undefined) { - actualVal = - payloadVal <= maxSuggestionCount ? payloadVal : maxSuggestionCount - } - state.extras.experimentSuggestionCount = actualVal >= 1 ? actualVal : 1 + const maxSuggestionCount = + action.payload.maxSuggestionCount ?? Number.MAX_VALUE + state.extras.experimentSuggestionCount = Math.max( + 1, + Math.min(maxSuggestionCount, payloadVal) + ) break } case 'copySuggestedToDataPoints': {