Skip to content

fix(onboarding): Preserve user-entered project slug during platform selection#109609

Merged
priscilawebdev merged 6 commits intomasterfrom
seer/fix/project-creation-slug-overwrite
Mar 6, 2026
Merged

fix(onboarding): Preserve user-entered project slug during platform selection#109609
priscilawebdev merged 6 commits intomasterfrom
seer/fix/project-creation-slug-overwrite

Conversation

@sentry
Copy link
Contributor

@sentry sentry bot commented Feb 27, 2026

This PR addresses a bug where a user-entered project slug would be overwritten when a platform was selected during the project creation onboarding flow.

Problem:
Previously, the logic in handlePlatformChange attempted to determine if the project name was user-modified by comparing formData.projectName with formData.platform?.key. This heuristic was flawed:

  1. If a user typed a project name that happened to match the currently selected platform's key, the system would incorrectly assume it was auto-generated and overwrite it when a different platform was selected.
  2. The useEffect that synced initialData to formData could inadvertently reset projectName if initialData re-evaluated (e.g., due to async team loading), clobbering user input.
  3. PlatformPicker's debounceSearch captures setPlatform from the initial render via useRef. When the user typed in the filter bar to auto-select a platform, the stale closure would call the first-render handlePlatformChange — where formData.projectName was still '' — wiping the user's slug even though the hasUserModifiedProjectName ref was correctly set to true.

Solution:

  1. Introduced a useRef, hasUserModifiedProjectName, to explicitly track whether the user has manually typed into the project slug input. This provides a reliable signal that the user intends to keep their custom name.
  2. The onChange handler now sets hasUserModifiedProjectName.current = true when the user types, and resets it to false if the field is cleared, allowing platform auto-fill to take over again.
  3. handlePlatformChange now uses a functional setFormData(prev => ...) updater instead of closing over formData.projectName. This ensures prev.projectName always reflects current state, even when the debounce fires with a stale closure.
  4. The useEffect that syncs initialData now skips projectName when hasUserModifiedProjectName.current is true, preventing async re-evaluation from clobbering user input.

Tests:
Added new test cases to createProject.spec.tsx to cover:

  • Ensuring a user-entered name (even one matching a platform key) is preserved when switching platforms.
  • Ensuring a user-entered slug is preserved when the filter bar auto-selects a platform via debounce.
  • Verifying that clearing the project name input allows platform selection to re-populate the field.

Ref NEW-769

@github-actions github-actions bot added the Scope: Frontend Automatically applied to PRs that change frontend components label Feb 27, 2026
@billyvg billyvg added the Trigger: getsentry tests Once code is reviewed: apply label to PR to trigger getsentry tests label Feb 27, 2026
@sentry sentry bot changed the title fix(project-creation): Preserve user-entered project slug during onboarding fix(onboarding): Preserve user-entered project slug during creation Feb 27, 2026
@sentry sentry bot force-pushed the seer/fix/project-creation-slug-overwrite branch from e8f4af1 to 9a11c80 Compare February 27, 2026 20:38
@github-actions github-actions bot removed the Trigger: getsentry tests Once code is reviewed: apply label to PR to trigger getsentry tests label Feb 27, 2026
@sentry sentry bot force-pushed the seer/fix/project-creation-slug-overwrite branch from 9a11c80 to b0c0b94 Compare February 27, 2026 20:42
@sentry sentry bot changed the title fix(onboarding): Preserve user-entered project slug during creation fix(onboarding): Preserve user-entered project slug during platform selection Feb 27, 2026
@linear
Copy link

linear bot commented Feb 27, 2026

@billyvg billyvg marked this pull request as ready for review February 27, 2026 20:43
@billyvg billyvg requested a review from a team as a code owner February 27, 2026 20:43
@billyvg billyvg self-assigned this Feb 27, 2026
Copy link
Contributor

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 2 potential issues.

Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

… slug

Initialize hasUserModifiedProjectName ref to true when autoFill
provides a pre-existing project name, preventing platform changes
from overwriting it. Guard the initialData useEffect to skip
projectName updates when the user has already modified the field,
avoiding desync when async team data loads.

Co-Authored-By: Claude <noreply@anthropic.com>
@billyvg billyvg added the Trigger: getsentry tests Once code is reviewed: apply label to PR to trigger getsentry tests label Mar 2, 2026
…rm auto-select

Use a functional setFormData updater in handlePlatformChange so that
prev.projectName always reflects current state, even when PlatformPicker's
debounceSearch holds a stale reference to the first-render handlePlatformChange.

Also adds a regression test covering the filter bar auto-selection case,
and drops the unnecessary async from the act() call in that test.

Co-Authored-By: Claude <noreply@anthropic.com>
@github-actions github-actions bot removed the Trigger: getsentry tests Once code is reviewed: apply label to PR to trigger getsentry tests label Mar 6, 2026
The browser POP navigation mounts CreateProject before
router.replace adds the autoFill query params, so useRef
initializes to false and never updates. Replace the static
useRef initializer with a useEffect that syncs the ref and
populates the projectName when autoFill transitions to true.

Also persist wasNameManuallyModified in localStorage so
auto-fill can distinguish user-typed slugs from platform-
derived ones.
@priscilawebdev priscilawebdev added the Trigger: getsentry tests Once code is reviewed: apply label to PR to trigger getsentry tests label Mar 6, 2026
Copy link
Member

@priscilawebdev priscilawebdev left a comment

Choose a reason for hiding this comment

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

I tested the changes and everything looks good. I found two additional bugs and have already pushed fixes to this PR.

@priscilawebdev priscilawebdev enabled auto-merge (squash) March 6, 2026 10:27
@priscilawebdev priscilawebdev merged commit b427647 into master Mar 6, 2026
84 of 89 checks passed
@priscilawebdev priscilawebdev deleted the seer/fix/project-creation-slug-overwrite branch March 6, 2026 10:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Scope: Frontend Automatically applied to PRs that change frontend components Trigger: getsentry tests Once code is reviewed: apply label to PR to trigger getsentry tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants