Target branch changes to default when source branch is changed in MR

Summary

When creating a new merge request, if we choose a target branch first and choose the source branch after, target branch is changed to the default branch again.

Steps to reproduce

  1. Select a project
  2. On the left, click on “Merge Requests”
  3. Click the “New merge request” button
  4. Immediately change the Target branch from the default to anything else
  5. Now change the “Source branch” to the branch desired
  6. The target branch switches to the default branch

What is the current bug behavior?

The target branch selection changes to the default branch if we choose the source branch after.

What is the expected correct behavior?

The target branch selection shouldn't change when we change the source branch.

Relevant logs and/or screenshots

After selecting the target branch:

target-branch-selection

After selecting the source branch (tager branch changed to main):

source-branch-selection

Output of checks

This bug appears after v16.6 in self-managed.

This bug happens on GitLab.com

Possible fixes

Choose the source branch before choosing a target branch.