Skip to content

Commit a1bf132

Browse files
committed
fix(cohorts): clamp gte+0 count input to 1
The count input's onChange only guarded against NaN, so typing 0 while the operator is "At least" produced {operator: 'gte', count: 0} — a frequency zFrequency rejects. Apply the same "At least 0 matches everyone" clamp the operator-change handler already uses.
1 parent a01f3d6 commit a1bf132

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

apps/start/src/components/cohort/cohort-criteria-builder.tsx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -308,11 +308,17 @@ function EventCriteriaItem({
308308
// rewrote a typed 0 back to 1 and "never did this event" could
309309
// not be entered.
310310
const parsed = Number.parseInt(e.target.value, 10);
311+
const operator = criteria.frequency?.operator ?? 'gte';
311312
onChange({
312313
...criteria,
313314
frequency: {
314-
operator: criteria.frequency?.operator ?? 'gte',
315-
count: Number.isNaN(parsed) ? 1 : parsed,
315+
operator,
316+
// Same "At least 0 matches everyone" clamp as the
317+
// operator-change handler above.
318+
count:
319+
Number.isNaN(parsed) || (operator === 'gte' && parsed === 0)
320+
? 1
321+
: parsed,
316322
},
317323
});
318324
}}

0 commit comments

Comments
 (0)