Skip to content

Commit

Permalink
Merge pull request makeplane#3290 from makeplane/develop
Browse files Browse the repository at this point in the history
fix: project settings form not loading new data while switching between projects
  • Loading branch information
sriramveeraghanta authored Dec 30, 2023
2 parents 447a8bc + 6e702d6 commit c3ba9f6
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
12 changes: 11 additions & 1 deletion web/components/project/form.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { FC } from "react";
import { FC, useEffect } from "react";
import { Controller, useForm } from "react-hook-form";
// components
import EmojiIconPicker from "components/emoji-icon-picker";
Expand Down Expand Up @@ -42,6 +42,7 @@ export const ProjectDetailsForm: FC<IProjectDetailsForm> = (props) => {
control,
setValue,
setError,
reset,
formState: { errors, isSubmitting },
} = useForm<IProject>({
defaultValues: {
Expand All @@ -51,6 +52,15 @@ export const ProjectDetailsForm: FC<IProjectDetailsForm> = (props) => {
},
});

useEffect(() => {
if (!project) return;
reset({
...project,
emoji_and_icon: project.emoji ?? project.icon_prop,
workspace: (project.workspace as IWorkspace).id,
});
}, [project, reset]);

const handleIdentifierChange = (event: React.ChangeEvent<HTMLInputElement>) => {
const { value } = event.target;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const GeneralSettingsPage: NextPageWithLayout = observer(() => {
const { workspaceSlug, projectId } = router.query;
// api call to fetch project details
useSWR(
workspaceSlug && projectId ? "PROJECT_DETAILS" : null,
workspaceSlug && projectId ? `PROJECT_DETAILS_${projectId}` : null,
workspaceSlug && projectId
? () => projectStore.fetchProjectDetails(workspaceSlug.toString(), projectId.toString())
: null
Expand Down

0 comments on commit c3ba9f6

Please sign in to comment.