fix: project select not working on the create issue modal (#1608)

This commit is contained in:
Aaryan Khandelwal 2023-07-23 22:12:13 +05:30 committed by GitHub
parent fdb7da4d45
commit 7669ee8755
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 50 additions and 67 deletions

View File

@ -96,13 +96,7 @@ export const IssueDescriptionForm: FC<IssueDetailsProps> = ({
setCharacterLimit(false); setCharacterLimit(false);
setIsSubmitting(true); setIsSubmitting(true);
handleSubmit(handleDescriptionFormSubmit)() handleSubmit(handleDescriptionFormSubmit)().finally(() => setIsSubmitting(false));
.then(() => {
setIsSubmitting(false);
})
.catch(() => {
setIsSubmitting(false);
});
}} }}
required={true} required={true}
className="min-h-10 block w-full resize-none overflow-hidden rounded border-none bg-transparent px-3 py-2 text-xl outline-none ring-0 focus:ring-1 focus:ring-custom-primary" className="min-h-10 block w-full resize-none overflow-hidden rounded border-none bg-transparent px-3 py-2 text-xl outline-none ring-0 focus:ring-1 focus:ring-custom-primary"
@ -110,7 +104,7 @@ export const IssueDescriptionForm: FC<IssueDetailsProps> = ({
disabled={!isAllowed} disabled={!isAllowed}
/> />
{characterLimit && ( {characterLimit && (
<div className="pointer-events-none absolute bottom-0 right-0 z-[2] rounded bg-custom-background-80 p-1 text-xs"> <div className="pointer-events-none absolute bottom-1 right-1 z-[2] rounded bg-custom-background-100 text-custom-text-200 p-0.5 text-xs">
<span <span
className={`${ className={`${
watch("name").length === 0 || watch("name").length > 255 ? "text-red-500" : "" watch("name").length === 0 || watch("name").length > 255 ? "text-red-500" : ""
@ -123,6 +117,7 @@ export const IssueDescriptionForm: FC<IssueDetailsProps> = ({
)} )}
</div> </div>
<span>{errors.name ? errors.name.message : null}</span> <span>{errors.name ? errors.name.message : null}</span>
<div className="relative">
<Controller <Controller
name="description" name="description"
control={control} control={control}
@ -149,13 +144,8 @@ export const IssueDescriptionForm: FC<IssueDetailsProps> = ({
onBlur={() => { onBlur={() => {
setIsSubmitting(true); setIsSubmitting(true);
handleSubmit(handleDescriptionFormSubmit)() handleSubmit(handleDescriptionFormSubmit)()
.then(() => { .then(() => setShowAlert(false))
setIsSubmitting(false); .finally(() => setIsSubmitting(false));
setShowAlert(false);
})
.catch(() => {
setIsSubmitting(false);
});
}} }}
placeholder="Description" placeholder="Description"
editable={isAllowed} editable={isAllowed}
@ -163,13 +153,12 @@ export const IssueDescriptionForm: FC<IssueDetailsProps> = ({
); );
}} }}
/> />
<div {isSubmitting && (
className={`absolute -bottom-8 right-0 text-sm text-custom-text-200 ${ <div className="absolute bottom-1 right-1 text-xs text-custom-text-200 bg-custom-background-100 p-3 z-10">
isSubmitting ? "block" : "hidden"
}`}
>
Saving... Saving...
</div> </div>
)}
</div>
</div> </div>
); );
}; };

View File

@ -261,8 +261,10 @@ export const IssueForm: FC<IssueFormProps> = ({
render={({ field: { value, onChange } }) => ( render={({ field: { value, onChange } }) => (
<IssueProjectSelect <IssueProjectSelect
value={value} value={value}
onChange={onChange} onChange={(val: string) => {
setActiveProject={setActiveProject} onChange(val);
setActiveProject(val);
}}
/> />
)} )}
/> />

View File

@ -95,9 +95,9 @@ export const CreateUpdateIssueModal: React.FC<IssuesModalProps> = ({
}; };
useEffect(() => { useEffect(() => {
if (projects && projects.length > 0) if (projects && projects.length > 0 && !activeProject)
setActiveProject(projects?.find((p) => p.id === projectId)?.id ?? projects?.[0].id ?? null); setActiveProject(projects?.find((p) => p.id === projectId)?.id ?? projects?.[0].id ?? null);
}, [projectId, projects]); }, [activeProject, projectId, projects]);
useEffect(() => { useEffect(() => {
const handleKeyDown = (e: KeyboardEvent) => { const handleKeyDown = (e: KeyboardEvent) => {

View File

@ -8,14 +8,9 @@ import { ClipboardDocumentListIcon } from "@heroicons/react/24/outline";
export interface IssueProjectSelectProps { export interface IssueProjectSelectProps {
value: string; value: string;
onChange: (value: string) => void; onChange: (value: string) => void;
setActiveProject: React.Dispatch<React.SetStateAction<string | null>>;
} }
export const IssueProjectSelect: React.FC<IssueProjectSelectProps> = ({ export const IssueProjectSelect: React.FC<IssueProjectSelectProps> = ({ value, onChange }) => {
value,
onChange,
setActiveProject,
}) => {
const { projects } = useProjects(); const { projects } = useProjects();
return ( return (
@ -29,10 +24,7 @@ export const IssueProjectSelect: React.FC<IssueProjectSelectProps> = ({
</span> </span>
</> </>
} }
onChange={(val: string) => { onChange={(val: string) => onChange(val)}
onChange(val);
setActiveProject(val);
}}
noChevron noChevron
> >
{projects ? ( {projects ? (