Do not execute compare action on mousedown events #9977
Merged
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.
Closes #9971
Description
This PR removes the call to
executeCompare()
that was performed on mousdedown events against the compare branch list.Context
Before this PR, two
executeCompare()
calls got executed when clicking on an item on the compare branch list: the first one happens on themousedown
event (the one I'm removing) and the second one on theclick
event (which happens after themouseup
event).This caused an issue when the first
executeCompare()
call finished before the click event happened:The
executeCompare()
action would update the filter text of the branch list with the selected branch name, causing the filter to be applied and therefore the branch list to get updated.Then, when the second
executeCompare()
function was called it could potentially use another branch since the list elements could get updated.In most situations where using a branch name as a filter won't match other branch names this didn't cause an issue, since after the first
executeCompare()
, the list of branches would only contain a single branch (the clicked branch) and the secondexecuteCompare()
action would be done against no item (and therefore ignored) or against the correct branch:But this could cause an issue in some scenarios where a branch name is a subset of another branch name, for example when having a branch called
X
and another one calledXY
. In this case the initial list would sort the branches by most recent ones:But once the user clicks on the
X
branch and theexecuteCompare()
action gets called, the filtering gets applied and the order of displayed branches changes:(this can be seen more clearly on the "Screenshots" section below).
About this PR
The call that I removed was introduced in #4412 to address an issue that is not present anymore in the compare branch UI (I've tested it with the changes of this PR), and I think that this is because with #4751 (which was merged a bit later) the whole need of the two
executeCompare()
calls is not needed anymore.Still, the logic of the compare branches UI is quite complex and I had a bit of trouble understanding all the different scenarios and how things play together, so it's possible that I'm missing something (I also found a couple of existing bugs while testing this PR which I'll document separately).
Screenshots
Before:
After:
Release notes
Notes: [Fixed] Select Branch to Compare no longer selects wrong branches