Fix input focus loss when creating a project
Some checks failed
CI / lint-and-test (push) Successful in 36s
CI / build (push) Has been cancelled
Deploy Production / deploy (push) Has been cancelled

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:
Julia McGhee
2026-03-21 20:45:12 +00:00
parent 7bb091d4b3
commit af090b1de2

View File

@@ -987,9 +987,7 @@ function ProjectsTab({ projects, setProjects, mobile }: {
);
};
const DetailView = () => {
if (creating) {
return (
const detailView = creating ? (
<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 }}>
{mobile && <BackBtn onBack={() => setCreating(false)} label="PROJECTS" />}
@@ -1006,18 +1004,7 @@ function ProjectsTab({ projects, setProjects, mobile }: {
</div>
</div>
</div>
);
}
if (!selectedProject) {
return (
<div style={{ flex: 1, display: "flex", alignItems: "center", justifyContent: "center" }}>
<Label color={tokens.color.text3}>SELECT A PROJECT</Label>
</div>
);
}
return (
) : selectedProject ? (
<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 }}>
{mobile && <BackBtn onBack={() => setSelectedId(null)} label="PROJECTS" />}
@@ -1071,8 +1058,11 @@ function ProjectsTab({ projects, setProjects, mobile }: {
<CredentialManager kind="git" mobile={mobile} />
</div>
</div>
) : (
<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, display: "flex", overflow: "hidden" }}>
@@ -1090,8 +1080,8 @@ function ProjectsTab({ projects, setProjects, mobile }: {
</div>
)}
{!mobile && <DetailView />}
{mobile && showDetail && <DetailView />}
{!mobile && detailView}
{mobile && showDetail && detailView}
</div>
);
}