From d26aa07c1063ea4864bf670317adc71b23d0a519 Mon Sep 17 00:00:00 2001 From: priyavrat7 Date: Tue, 21 Jul 2026 15:45:06 -0400 Subject: [PATCH] Fix race condition in new_profile auto-selection and enable autoSelect 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. --- modules/new_profile/jsx/NewProfileIndex.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/modules/new_profile/jsx/NewProfileIndex.js b/modules/new_profile/jsx/NewProfileIndex.js index 475d94845b..e501ebb982 100644 --- a/modules/new_profile/jsx/NewProfileIndex.js +++ b/modules/new_profile/jsx/NewProfileIndex.js @@ -213,10 +213,9 @@ class NewProfileIndex extends React.Component { * @param {string} value - selected value for corresponding form element */ setFormData(formElement, value) { - let formData = Object.assign({}, this.state.formData); - formData[formElement] = value; - - this.setState({formData: formData}); + this.setState((prevState) => ({ + formData: Object.assign({}, prevState.formData, {[formElement]: value}), + })); } /** @@ -294,6 +293,7 @@ class NewProfileIndex extends React.Component { onUserInput = {this.setFormData} value = {this.state.formData.site} required = {true} + autoSelect = {true} />; } const fields = [ @@ -364,6 +364,7 @@ class NewProfileIndex extends React.Component { onUserInput = {this.setFormData} value = {this.state.formData.project} required = {true} + autoSelect = {true} /> ), },