Fix input focus loss when creating a project
DetailView was defined as a component inside ProjectsTab's render, causing React to unmount/remount it on every keystroke. Replace with inline JSX so the input element identity stays stable across renders.
This commit is contained in:
@@ -987,9 +987,7 @@ function ProjectsTab({ projects, setProjects, mobile }: {
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
const DetailView = () => {
|
const detailView = creating ? (
|
||||||
if (creating) {
|
|
||||||
return (
|
|
||||||
<div style={{ flex: 1, overflow: "auto", display: "flex", flexDirection: "column" }}>
|
<div style={{ flex: 1, overflow: "auto", display: "flex", flexDirection: "column" }}>
|
||||||
<div style={{ padding: `${tokens.space[3]}px ${tokens.space[4]}px`, borderBottom: `1px solid ${tokens.color.border0}`, flexShrink: 0, background: tokens.color.bg0 }}>
|
<div style={{ padding: `${tokens.space[3]}px ${tokens.space[4]}px`, borderBottom: `1px solid ${tokens.color.border0}`, flexShrink: 0, background: tokens.color.bg0 }}>
|
||||||
{mobile && <BackBtn onBack={() => setCreating(false)} label="PROJECTS" />}
|
{mobile && <BackBtn onBack={() => setCreating(false)} label="PROJECTS" />}
|
||||||
@@ -1006,18 +1004,7 @@ function ProjectsTab({ projects, setProjects, mobile }: {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
) : selectedProject ? (
|
||||||
}
|
|
||||||
|
|
||||||
if (!selectedProject) {
|
|
||||||
return (
|
|
||||||
<div style={{ flex: 1, display: "flex", alignItems: "center", justifyContent: "center" }}>
|
|
||||||
<Label color={tokens.color.text3}>SELECT A PROJECT</Label>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
|
||||||
<div style={{ flex: 1, overflow: "hidden", display: "flex", flexDirection: "column" }}>
|
<div style={{ flex: 1, overflow: "hidden", display: "flex", flexDirection: "column" }}>
|
||||||
<div style={{ padding: `${tokens.space[3]}px ${tokens.space[4]}px`, borderBottom: `1px solid ${tokens.color.border0}`, flexShrink: 0, background: tokens.color.bg0 }}>
|
<div style={{ padding: `${tokens.space[3]}px ${tokens.space[4]}px`, borderBottom: `1px solid ${tokens.color.border0}`, flexShrink: 0, background: tokens.color.bg0 }}>
|
||||||
{mobile && <BackBtn onBack={() => setSelectedId(null)} label="PROJECTS" />}
|
{mobile && <BackBtn onBack={() => setSelectedId(null)} label="PROJECTS" />}
|
||||||
@@ -1071,8 +1058,11 @@ function ProjectsTab({ projects, setProjects, mobile }: {
|
|||||||
<CredentialManager kind="git" mobile={mobile} />
|
<CredentialManager kind="git" mobile={mobile} />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
) : (
|
||||||
|
<div style={{ flex: 1, display: "flex", alignItems: "center", justifyContent: "center" }}>
|
||||||
|
<Label color={tokens.color.text3}>SELECT A PROJECT</Label>
|
||||||
|
</div>
|
||||||
);
|
);
|
||||||
};
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div style={{ flex: 1, display: "flex", overflow: "hidden" }}>
|
<div style={{ flex: 1, display: "flex", overflow: "hidden" }}>
|
||||||
@@ -1090,8 +1080,8 @@ function ProjectsTab({ projects, setProjects, mobile }: {
|
|||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{!mobile && <DetailView />}
|
{!mobile && detailView}
|
||||||
{mobile && showDetail && <DetailView />}
|
{mobile && showDetail && detailView}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user