Skip to content

fix(projects): prefill project name so Create is enabled on load - #10

Merged
MeepCastana merged 2 commits into
developfrom
fix/projects-new-default-name
Aug 6, 2026
Merged

MeepCastana merged 2 commits into
developfrom
fix/projects-new-default-name

Conversation

@OGtwelve

@OGtwelve OGtwelve commented Aug 6, 2026

Copy link
Copy Markdown
Collaborator

Fixes #3

Stacked on #9 (base branch fix/projects-new-h1) — merge that first; GitHub will retarget this to main automatically.

What

Create Project was disabled on page load with nothing explaining why: name is required, the form validates onChange, and an untouched field shows no error.

How

The issue's preferred option (1):

  • new.tsx passes defaultValues={{ name: 'Project N' }} — N from the project count (the store is preloaded in the route's beforeLoad). The object is memoized once on mount: ProjectForm resets whenever the defaultValues identity changes, so it must be stable.
  • ProjectForm focuses the name field with the text selected on mount, create flow only (!isEditing) so the edit dialog's (Radix) focus management is untouched.

Two implementation notes for review:

  • The focus effect is declared after the reset effect on purpose — reset() rewrites the input value, which collapses any selection made before it runs (verified: with the order flipped, the caret sits at the end instead of selecting).
  • It uses direct DOM focus()/select() on the #name input rather than RHF's setFocus(..., { shouldSelect: true }) — setFocus silently did nothing in this form (reproducibly, while manual DOM focus worked). If anyone knows why, happy to switch.

Verification

Headless Chromium against the dev server (promo already dismissed):

  • On load: value Project 1, field focused, text fully selected [0, 9], Create enabled
  • Typing replaces the selection (My Film)
  • Clearing the name: button disables and "Project name is required" is shown
  • Fresh load → clicking Create Project immediately → project created, navigated to /editor/…

Known interaction, out of scope here: on a first-ever visit the Kubeez welcome promo steals focus, so the field is not focused after dismissing it. That's the promo-over-the-flow problem tracked in #1.

lint ✅, projects tests ✅

The route passed hideHeader to ProjectForm (suppressing its h1) and
rendered only the logo in its own header bar, leaving the page with no
heading at all — nothing visible saying what the screen is, and no
document heading for screen-reader navigation.

Render the h1 in the route header next to the logo, separated by a
divider, per the issue's preferred option: the heading shares the
existing bar instead of stacking a second one.
The Create Project button was disabled the moment /projects/new loaded:
name is required, the form validates onChange, and the untouched field
showed no validation message — a dead primary button with no explanation.

Prefill the name as 'Project N' (N from the loaded project count, store
is preloaded in beforeLoad) and focus the field with the text selected,
so a first-time visitor can submit immediately or just type over the
default. The defaultValues object is memoized once on mount — a stable
identity, since ProjectForm resets whenever it changes.

Focus + select runs in an effect declared after the reset effect
(reset() rewrites the input value, which collapses any earlier
selection) and is limited to the create flow (!isEditing) to stay out of
the edit dialog's focus management.

@MeepCastana MeepCastana left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed locally on a combined review branch (all six merged clean, no conflicts). CI green. Approved.

@MeepCastana
MeepCastana merged commit 8665182 into develop Aug 6, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Create Project button is disabled on load with no explanation

2 participants