Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Fix summary & description fields deleting user's text (sometimes) after a commit #11345

Merged
merged 2 commits into from
Jan 8, 2021

Conversation

sergiou87
Copy link
Member

Closes #7251

Description

This PR tackles a problem where the component CommitMessage could clear the summary and description textfields a few seconds after the commit completed, when the user might already have written something for their next commit.

The problem was CommitMessage relied on the repository.state.isCommitting attribute to enable/disable the textfields, but wouldn't clear the textfields until the commit + some additional tasks were finished. So the timeline would look something like this:

  1. Set repository.state.isCommitting = true (textfields are now disabled)
  2. Do commit work
  3. Set repository.state.isCommitting = false (textfields are now enabled)
  4. Do additional commit work (refreshing repository and change list).
  5. Clear the textfields.

This bug surfaces when step (4) takes too long, which is when the user might be preparing their next commit message, just to see how it gets deleted in step (5).

With this PR, the timeline of events looks like this:

  1. Set repository.state.isCommitting = true (textfields are now disabled)
  2. Do commit work
  3. Do additional commit work (refreshing repository and change list).
  4. Set repository.state.isCommitting = false (textfields are now enabled)
  5. Clear the textfields.

Now the the textfields will be cleared right after enabling them again.

Release notes

Notes: [Fixed] Commit messages won't be cleared while the user is writing them.

Comment on lines +3581 to +3584
private async withIsCommitting(
repository: Repository,
fn: () => Promise<string | undefined>
): Promise<boolean | undefined> {
fn: () => Promise<boolean>
): Promise<boolean> {
Copy link
Member Author

@sergiou87 sergiou87 Jan 8, 2021

Choose a reason for hiding this comment

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

Aside from renaming this function as @niik suggested, I also changed the return type to (hopefully) simplify the code, specially after moving things around.

Comment on lines +779 to +782
invalidationProps={{
workingDirectory: this.props.workingDirectory,
isCommitting: this.props.isCommitting,
}}
Copy link
Member Author

Choose a reason for hiding this comment

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

After the changes in this PR, I noticed the checkboxes of the files in the change list stayed disabled. Putting the _refreshDirectory and refreshChangesSection inside the withIsCommitting block meant that the workingDirectory prop would change before isCommitting is set to false. And when that happens, it wouldn't trigger a render on the list.

Copy link
Member

@niik niik left a comment

Choose a reason for hiding this comment

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

high-five

@niik niik merged commit 43c7e3a into development Jan 8, 2021
@niik niik deleted the clear-after-commit-fix branch January 8, 2021 16:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Commit Message Clears When Committing in Stages
2 participants