diff --git a/apps/app/components/labels/create-update-label-inline.tsx b/apps/app/components/labels/create-update-label-inline.tsx index a58da94ac..24db3ab38 100644 --- a/apps/app/components/labels/create-update-label-inline.tsx +++ b/apps/app/components/labels/create-update-label-inline.tsx @@ -1,4 +1,4 @@ -import React, { useEffect } from "react"; +import React, { forwardRef, useEffect } from "react"; import { useRouter } from "next/router"; @@ -31,12 +31,12 @@ const defaultValues: Partial = { color: "#ff0000", }; -export const CreateUpdateLabelInline: React.FC = ({ - labelForm, - setLabelForm, - isUpdating, - labelToUpdate, -}) => { +type Ref = HTMLDivElement; + +export const CreateUpdateLabelInline = forwardRef(function CreateUpdateLabelInline( + { labelForm, setLabelForm, isUpdating, labelToUpdate }, + ref +) { const router = useRouter(); const { workspaceSlug, projectId } = router.query; @@ -109,9 +109,10 @@ export const CreateUpdateLabelInline: React.FC = ({ return (
@@ -187,4 +188,4 @@ export const CreateUpdateLabelInline: React.FC = ({ )}
); -}; +}); diff --git a/apps/app/pages/[workspaceSlug]/projects/[projectId]/settings/labels.tsx b/apps/app/pages/[workspaceSlug]/projects/[projectId]/settings/labels.tsx index 7044162b3..534409ec4 100644 --- a/apps/app/pages/[workspaceSlug]/projects/[projectId]/settings/labels.tsx +++ b/apps/app/pages/[workspaceSlug]/projects/[projectId]/settings/labels.tsx @@ -1,4 +1,4 @@ -import React, { useState } from "react"; +import React, { useState, useRef } from "react"; import { useRouter } from "next/router"; @@ -46,6 +46,8 @@ const LabelsSettings: NextPage = (props) => { const router = useRouter(); const { workspaceSlug, projectId } = router.query; + const scollToRef = useRef(null); + const { data: projectDetails } = useSWR( workspaceSlug && projectId ? PROJECT_DETAILS(projectId as string) : null, workspaceSlug && projectId @@ -128,6 +130,7 @@ const LabelsSettings: NextPage = (props) => { setLabelForm={setLabelForm} isUpdating={isUpdating} labelToUpdate={labelToUpdate} + ref={scollToRef} /> )} <> @@ -142,7 +145,12 @@ const LabelsSettings: NextPage = (props) => { key={label.id} label={label} addLabelToGroup={() => addLabelToGroup(label)} - editLabel={editLabel} + editLabel={(label) => { + editLabel(label); + scollToRef.current?.scrollIntoView({ + behavior: "smooth", + }); + }} handleLabelDelete={handleLabelDelete} /> ); @@ -153,7 +161,12 @@ const LabelsSettings: NextPage = (props) => { label={label} labelChildren={children} addLabelToGroup={addLabelToGroup} - editLabel={editLabel} + editLabel={(label) => { + editLabel(label); + scollToRef.current?.scrollIntoView({ + behavior: "smooth", + }); + }} handleLabelDelete={handleLabelDelete} /> );