-
-
Notifications
You must be signed in to change notification settings - Fork 4.6k
fix(onboarding): Preserve user-entered project slug during platform selection #109609
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -192,6 +192,7 @@ export function CreateProject() { | |
|
|
||
| const [formData, setFormData] = useState<FormData>(initialData); | ||
| const pickerKeyRef = useRef<'create-project' | 'auto-fill'>('create-project'); | ||
| const hasUserModifiedProjectName = useRef(false); | ||
|
|
||
| const canCreateTeam = organization.access.includes('project:admin'); | ||
| const isOrgMemberWithNoAccess = accessTeams.length === 0 && !canCreateTeam; | ||
|
|
@@ -442,13 +443,11 @@ export function CreateProject() { | |
| key: value.id, | ||
| }); | ||
|
|
||
| const userModifiedName = | ||
| !!formData.projectName && formData.projectName !== formData.platform?.key; | ||
| const newName = userModifiedName ? formData.projectName : value.id; | ||
| const newName = hasUserModifiedProjectName.current ? formData.projectName : value.id; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. AutoFill project name overwritten on platform changeLow Severity When Additional Locations (1) |
||
|
|
||
| updateFormData('projectName', newName); | ||
| }, | ||
| [updateFormData, formData.projectName, formData.platform?.key, organization] | ||
| [updateFormData, formData.projectName, organization] | ||
| ); | ||
|
|
||
| const platform = formData.platform?.key; | ||
|
|
@@ -520,7 +519,13 @@ export function CreateProject() { | |
| placeholder={t('project-slug')} | ||
| autoComplete="off" | ||
| value={formData.projectName} | ||
| onChange={e => updateFormData('projectName', slugify(e.target.value))} | ||
| onChange={e => { | ||
| const slugified = slugify(e.target.value); | ||
| // Track whether the user has intentionally set a custom name. | ||
| // Reset if they clear the field so platform selection can fill it in again. | ||
| hasUserModifiedProjectName.current = slugified !== ''; | ||
| updateFormData('projectName', slugified); | ||
| }} | ||
| /> | ||
| </ProjectNameInputWrap> | ||
| </div> | ||
|
|
||


There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ref not reset when useEffect clobbers project name
Medium Severity
The
hasUserModifiedProjectNameref can desync from actual form state. The existinguseEffect(lines 247–251) resetsformData.projectNameto''wheneverinitialDatachanges (e.g., whendefaultTeamupdates due to async team loading), but does not resethasUserModifiedProjectName. After this, the ref istruewhile the project name is empty, so subsequent platform selection preserves the empty string instead of auto-filling the platform name — a regression from the old behavior which would auto-fill for empty names.Additional Locations (2)
static/app/views/projectInstall/createProject.tsx#L246-L251static/app/views/projectInstall/createProject.tsx#L445-L446