Skip to content

Commit

Permalink
fix: reset input fields in API delete dialog after reopening
Browse files Browse the repository at this point in the history
  • Loading branch information
Vardhaman619 committed Oct 11, 2024
1 parent 0608fee commit 4d3f8cf
Showing 1 changed file with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"use client";
import { Button } from "@/components/ui/button";
import type React from "react";
import { useState } from "react";
import { useEffect, useState } from "react";

import { Card, CardDescription, CardFooter, CardHeader, CardTitle } from "@/components/ui/card";
import { Input } from "@/components/ui/input";
Expand Down Expand Up @@ -84,6 +84,13 @@ export const DeleteApi: React.FC<Props> = ({ api, keys }) => {
deleteApi.mutate({ apiId: api.id });
}

// useEffect to reset form fields when dialog is closed
useEffect(() => {
if (!open) {
form.reset(); // Reset form when the dialog is closed
}
}, [open, form.reset]); // Run this whenever `open` changes

return (
<>
<Card
Expand Down

0 comments on commit 4d3f8cf

Please sign in to comment.