Skip to content

Commit

Permalink
fix: selecting label once create using modal (#1537)
Browse files Browse the repository at this point in the history
  • Loading branch information
dakshesh14 authored Jul 18, 2023
1 parent 16a7bd3 commit 9d891ec
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
4 changes: 4 additions & 0 deletions apps/app/components/issues/form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,10 @@ export const IssueForm: FC<IssueFormProps> = ({
handleClose={() => setLabelModal(false)}
projectId={projectId}
user={user}
onSuccess={(response) => {
setValue("labels", [...watch("labels"), response.id]);
setValue("labels_list", [...watch("labels_list"), response.id]);
}}
/>
</>
)}
Expand Down
10 changes: 9 additions & 1 deletion apps/app/components/labels/create-label-modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ type Props = {
isOpen: boolean;
projectId: string;
handleClose: () => void;
onSuccess?: (response: IIssueLabels) => void;
user: ICurrentUserResponse | undefined;
};

Expand All @@ -34,7 +35,13 @@ const defaultValues: Partial<IState> = {
color: "rgb(var(--color-text-200))",
};

export const CreateLabelModal: React.FC<Props> = ({ isOpen, projectId, handleClose, user }) => {
export const CreateLabelModal: React.FC<Props> = ({
isOpen,
projectId,
handleClose,
user,
onSuccess,
}) => {
const router = useRouter();
const { workspaceSlug } = router.query;

Expand Down Expand Up @@ -66,6 +73,7 @@ export const CreateLabelModal: React.FC<Props> = ({ isOpen, projectId, handleClo
false
);
onClose();
if (onSuccess) onSuccess(res);
})
.catch((error) => {
console.log(error);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -553,6 +553,11 @@ const SinglePage: NextPage = () => {
handleClose={() => setLabelModal(false)}
projectId={projectId}
user={user}
onSuccess={(response) => {
partialUpdatePage({
labels_list: [...(pageDetails.labels ?? []), response.id],
});
}}
/>
)}
</>
Expand Down

0 comments on commit 9d891ec

Please sign in to comment.