Skip to content

Commit

Permalink
[login/request account] Weird ordering of projects in dropdown (#7795)
Browse files Browse the repository at this point in the history
Solves the incorrect order of dropdowns of select when no label is being used for login design.

    Resolves #7790
  • Loading branch information
maltheism authored Nov 8, 2021
1 parent 1f270b4 commit 6356a1e
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
8 changes: 8 additions & 0 deletions jsx/Form.js
Original file line number Diff line number Diff line change
Expand Up @@ -591,6 +591,12 @@ class SelectElement extends Component {
});
}

if (this.props.placeholder !== '') {
optionList.unshift(<option value={''} selected={true}>
{this.props.placeholder}
</option>);
}

// Default to empty string for regular select and to empty array for 'multiple' select
const value = this.props.value || (multiple ? [] : '');

Expand Down Expand Up @@ -653,6 +659,7 @@ SelectElement.propTypes = {
errorMessage: PropTypes.string,
onUserInput: PropTypes.func,
noMargins: PropTypes.bool,
placeholder: PropTypes.string,
};

SelectElement.defaultProps = {
Expand All @@ -673,6 +680,7 @@ SelectElement.defaultProps = {
console.warn('onUserInput() callback is not set');
},
noMargins: false,
placeholder: '',
};

/**
Expand Down
2 changes: 0 additions & 2 deletions modules/login/jsx/loginIndex.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,6 @@ class Login extends Component {
state.study.logo = window.location.origin
+ '/' + json.login.logo;
// request account setup.
json.requestAccount.site[''] = 'Choose your site:';
json.requestAccount.project[''] = 'Choose your project:';
state.component.requestAccount = json.requestAccount;
state.isLoaded = true;
this.setState(state);
Expand Down
2 changes: 2 additions & 0 deletions modules/login/jsx/requestAccount.js
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@ class RequestAccount extends Component {
onUserInput={this.setForm}
emptyOption={false}
required={true}
placeholder={'Choose your site:'}
/>
<SelectElement
name={'project'}
Expand All @@ -200,6 +201,7 @@ class RequestAccount extends Component {
onUserInput={this.setForm}
emptyOption={false}
required={true}
placeholder={'Choose your project:'}
/>
<CheckboxElement
name={'examiner'}
Expand Down

0 comments on commit 6356a1e

Please sign in to comment.