Skip to content

Commit cd8b3c7

Browse files
committed
fix: stabilize alert form reset
1 parent a5fccbe commit cd8b3c7

2 files changed

Lines changed: 15 additions & 14 deletions

File tree

  • apps/webapp/app/routes/_app.orgs.$organizationSlug.projects.$projectParam.env.$envParam.alerts.new
  • internal-packages/dashboard-agent/src/__snapshots__

‎apps/webapp/app/routes/_app.orgs.$organizationSlug.projects.$projectParam.env.$envParam.alerts.new/route.tsx‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { Form, useActionData, useNavigate, useNavigation } from "@remix-run/reac
55
import { type LoaderFunctionArgs } from "@remix-run/router";
66
import { type ActionFunctionArgs, json } from "@remix-run/server-runtime";
77
import { SlackIcon } from "@trigger.dev/companyicons";
8-
import { useEffect, useState } from "react";
8+
import { useEffect, useRef, useState } from "react";
99
import { typedjson, useTypedLoaderData } from "remix-typedjson";
1010
import { z } from "zod";
1111
import { InlineCode } from "~/components/code/InlineCode";
@@ -247,6 +247,7 @@ export default function Page() {
247247
const project = useProject();
248248
const environment = useEnvironment();
249249
const [currentAlertChannel, setCurrentAlertChannel] = useState<string | null>(option ?? "EMAIL");
250+
const formRef = useRef<HTMLFormElement>(null);
250251

251252
const [selectedSlackChannelValue, setSelectedSlackChannelValue] = useState<string | undefined>();
252253

@@ -276,8 +277,8 @@ export default function Page() {
276277
if (navigation.state !== "idle") return;
277278
if (lastSubmission !== undefined) return;
278279

279-
form.reset();
280-
}, [navigation.state, lastSubmission, form]);
280+
formRef.current?.reset();
281+
}, [navigation.state, lastSubmission]);
281282

282283
return (
283284
<Dialog
@@ -290,7 +291,7 @@ export default function Page() {
290291
>
291292
<DialogContent>
292293
<DialogHeader>New alert</DialogHeader>
293-
<Form method="post" {...getFormProps(form)}>
294+
<Form ref={formRef} method="post" {...getFormProps(form)}>
294295
<Fieldset className="mt-2">
295296
<InputGroup fullWidth>
296297
<SegmentedControl

‎internal-packages/dashboard-agent/src/__snapshots__/prompt-prefix.test.ts.snap‎

Lines changed: 10 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)