Skip to content

Commit

Permalink
fix clearable insight dropdowns
Browse files Browse the repository at this point in the history
  • Loading branch information
xvvvyz committed Jul 25, 2024
1 parent db5a924 commit 0339d29
Showing 1 changed file with 16 additions and 16 deletions.
32 changes: 16 additions & 16 deletions app/_components/insight-form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -142,19 +142,6 @@ const InsightForm = ({ events, insight, subjectId }: InsightFormProps) => {
}
};

const onInputChange = (inputId: string) => {
form.setValue('includeEventsFrom', null);
form.setValue('includeEventsSince', null);

onMarkOrInputChange({
inputId,
showBars,
showDots,
showLine,
showLinearRegression,
});
};

return (
<form
className="flex flex-col gap-8 px-4 pb-8 pt-6 sm:px-8"
Expand Down Expand Up @@ -190,7 +177,16 @@ const InsightForm = ({ events, insight, subjectId }: InsightFormProps) => {
onChange={(value) => {
const inputId = (value as IOption).id;
field.onChange(inputId);
onInputChange(inputId);
form.setValue('includeEventsFrom', null);
form.setValue('includeEventsSince', null);

onMarkOrInputChange({
inputId,
showBars,
showDots,
showLine,
showLinearRegression,
});
}}
options={inputOptions}
placeholder="Select an input…"
Expand Down Expand Up @@ -345,7 +341,9 @@ const InsightForm = ({ events, insight, subjectId }: InsightFormProps) => {
label="Events from"
name={field.name}
onBlur={field.onBlur}
onChange={(value) => field.onChange((value as IOption)?.id)}
onChange={(value) =>
field.onChange((value as IOption)?.id ?? null)
}
options={eventTypeOrTrainingPlanOptions}
placeholder="All event types/training plans…"
value={value}
Expand All @@ -362,7 +360,9 @@ const InsightForm = ({ events, insight, subjectId }: InsightFormProps) => {
label="Events since"
name={field.name}
onBlur={field.onBlur}
onChange={(value) => field.onChange((value as IOption)?.id)}
onChange={(value) =>
field.onChange((value as IOption)?.id ?? null)
}
options={INCLUDE_EVENTS_SINCE_OPTIONS}
placeholder="The beginning of time…"
value={INCLUDE_EVENTS_SINCE_OPTIONS.find(
Expand Down

0 comments on commit 0339d29

Please sign in to comment.