[modules | new_profile] fix for enabling default unique options for Site and Project - #10974
Merged
driusan merged 1 commit intoJul 22, 2026
Conversation
…t for Site/Project
Updated `setFormData` in NewProfileIndex to use functional state updates,
resolving a race condition where concurrent auto-selections overwrote each other.
Enabled `autoSelect={true}` on the Site and Project dropdowns to correctly default
to unique options for restricted users.
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.
Situation:
When a user creates a candidate on the
new_profilepage and clicks "Recruit another candidate", the page reloads. For users with a single unique Site or Project affiliation, these dropdowns were failing to automatically select the only available option, in case of uniqueness.Task:
To ensure that form dropdowns with exactly one available option (such as Site and Project) are automatically selected, and ensure that parallel state updates from multiple auto-selecting fields do not overwrite one another.
Action:
autoSelect={true}property to the Site and Project<SelectElement>components inNewProfileIndex.jsso they naturally default to their single options.setFormDatamethod to use React's functional state updates (prevState). Previously, it read the state synchronously, causing a race condition where theProjectelement would read stale state and overwrite the selection made by theSiteelement fraction of a second prior.Result:
The form now auto-selects unique affiliations upon page load. Users with restricted access can see their unique Site and Project and if there are multiple sites and projects, auto-select will not happen.
As in the screenshot attached, there is only one site and one project after clicking on "Recruit another candidate"

This PR closes #10901