fix(onboarding): Preserve user-entered project slug during platform selection#109609
Merged
priscilawebdev merged 6 commits intomasterfrom Mar 6, 2026
Merged
Conversation
e8f4af1 to
9a11c80
Compare
9a11c80 to
b0c0b94
Compare
Contributor
There was a problem hiding this comment.
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>
…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>
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
approved these changes
Mar 6, 2026
Member
priscilawebdev
left a comment
There was a problem hiding this comment.
I tested the changes and everything looks good. I found two additional bugs and have already pushed fixes to this PR.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
handlePlatformChangeattempted to determine if the project name was user-modified by comparingformData.projectNamewithformData.platform?.key. This heuristic was flawed:useEffectthat syncedinitialDatatoformDatacould inadvertently resetprojectNameifinitialDatare-evaluated (e.g., due to async team loading), clobbering user input.PlatformPicker'sdebounceSearchcapturessetPlatformfrom the initial render viauseRef. When the user typed in the filter bar to auto-select a platform, the stale closure would call the first-renderhandlePlatformChange— whereformData.projectNamewas still''— wiping the user's slug even though thehasUserModifiedProjectNameref was correctly set totrue.Solution:
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.onChangehandler now setshasUserModifiedProjectName.current = truewhen the user types, and resets it tofalseif the field is cleared, allowing platform auto-fill to take over again.handlePlatformChangenow uses a functionalsetFormData(prev => ...)updater instead of closing overformData.projectName. This ensuresprev.projectNamealways reflects current state, even when the debounce fires with a stale closure.useEffectthat syncsinitialDatanow skipsprojectNamewhenhasUserModifiedProjectName.currentistrue, preventing async re-evaluation from clobbering user input.Tests:
Added new test cases to
createProject.spec.tsxto cover:Ref NEW-769