Skip to content

Database governance built for humans and agents — controlling changes and access across every major database.

fix(plan): autofocus title input on plan creation (#20368)

Danny Xu2d0c31c4df45
diff --git a/frontend/src/react/pages/project/plan-detail/components/PlanDetailHeader.tsx b/frontend/src/react/pages/project/plan-detail/components/PlanDetailHeader.tsx
index 46c24353a1..bce0b6e798 100644
--- a/frontend/src/react/pages/project/plan-detail/components/PlanDetailHeader.tsx
+++ b/frontend/src/react/pages/project/plan-detail/components/PlanDetailHeader.tsx
@@ -1,6 +1,6 @@
import { clone, create } from "@bufbuild/protobuf";
import { Ban, ChevronUp, Loader2, Menu, Plus } from "lucide-react";
-import { useEffect, useMemo, useState } from "react";
+import { useEffect, useMemo, useRef, useState } from "react";
import { useTranslation } from "react-i18next";
import { issueServiceClientConnect, planServiceClientConnect } from "@/connect";
import {
@@ -72,6 +72,8 @@ export function PlanDetailHeader() {
useState(false);
const [submittingReview, setSubmittingReview] = useState(false);
const { emptySpecIdSet } = usePlanDetailSpecValidation(page.plan.specs ?? []);
+ const titleInputRef = useRef<HTMLInputElement>(null);
+ const titleAutoFocusedRef = useRef(false);
useEffect(() => {
const nextTitle = page.issue?.title ?? page.plan.title;
@@ -123,6 +125,19 @@ export function PlanDetailHeader() {
project,
]);
+ useEffect(() => {
+ // Route changes within the plan-detail page (create → existing → create)
+ // re-render the same React root, so the guard must reset when leaving
+ // create mode — otherwise the next create visit never re-focuses.
+ if (!page.isCreating) {
+ titleAutoFocusedRef.current = false;
+ return;
+ }
+ if (!page.ready || titleAutoFocusedRef.current) return;
+ titleAutoFocusedRef.current = true;
+ titleInputRef.current?.focus();
+ }, [page.isCreating, page.ready]);
+
const showSubmitForReview =
!!page.plan.name &&
!page.isCreating &&
@@ -442,6 +457,7 @@ export function PlanDetailHeader() {
)}
<div className="min-w-0 flex-1">
<input
+ ref={titleInputRef}
className={cn(
"h-9 w-full bg-transparent text-xl! font-bold text-main outline-hidden",
editingTitle