Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

[new_profile] Pressing create multiple time creates multiple candidates "silently" #5808

Merged
merged 6 commits into from
Nov 29, 2019
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions jsx/Form.js
Original file line number Diff line number Diff line change
Expand Up @@ -1559,6 +1559,7 @@ class ButtonElement extends Component {
type={this.props.type}
className={this.props.buttonClass}
onClick={this.handleClick}
disabled={this.props.disabled}
>
{this.props.label}
</button>
Expand All @@ -1572,6 +1573,7 @@ ButtonElement.propTypes = {
name: PropTypes.string,
label: PropTypes.string,
type: PropTypes.string,
disabled: PropTypes.bool,
maltheism marked this conversation as resolved.
Show resolved Hide resolved
onUserInput: PropTypes.func,
};

Expand Down
5 changes: 5 additions & 0 deletions modules/new_profile/jsx/NewProfileIndex.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ class NewProfileIndex extends React.Component {
isLoaded: false,
isCreated: false,
error: false,
disable: false,
};
this.handleSubmit = this.handleSubmit.bind(this);
this.setFormData = this.setFormData.bind(this);
Expand Down Expand Up @@ -89,6 +90,9 @@ class NewProfileIndex extends React.Component {
}
formObject.append('fire_away', 'New Candidate');

// disable form from resubmission.
this.setState({disable: true});
Copy link
Collaborator

@HenriRabalais HenriRabalais Nov 28, 2019

Choose a reason for hiding this comment

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

I would call this something a bit more descriptive like disableSubmit or something to that effect. Perhaps submitDisabled because it is written as more of a state (true/false) whereas disable sounds like an action (i.e. function).

Copy link
Collaborator

Choose a reason for hiding this comment

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

Also, I think if the submission fails, the button should be re-enabled so that the user can attempt another submission.

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks @HenriRabalais, I added the suggested changes.


fetch(this.props.submitURL, {
method: 'POST',
cache: 'no-cache',
Expand Down Expand Up @@ -240,6 +244,7 @@ class NewProfileIndex extends React.Component {
label = "Create"
id = "button"
type = "submit"
disabled={this.state.disable}
/>
</FormElement>
);
Expand Down