@@ -33,6 +33,7 @@ define(function (require, exports) {
3333 $dropdown ;
3434
3535 let lastRenderedBranchName = null ;
36+ let $dropdownAnchor = null ;
3637
3738 function renderList ( branches ) {
3839 branches = branches . map ( function ( name ) {
@@ -329,6 +330,7 @@ define(function (require, exports) {
329330 // $(window).off("keydown", keydownHook);
330331
331332 $dropdown = null ;
333+ $dropdownAnchor = null ;
332334 }
333335
334336 function _positionDropdownBelow ( $toggle ) {
@@ -388,17 +390,24 @@ define(function (require, exports) {
388390 // so it has to be captured before the async branch listing below
389391 const $anchor = $ ( e . currentTarget ) ;
390392
391- // If the dropdown is already visible, close it
393+ // clicking the anchor that opened the dropdown closes it, clicking the
394+ // other anchor moves the dropdown there
392395 if ( $dropdown ) {
396+ const sameAnchor = $dropdownAnchor && $dropdownAnchor [ 0 ] === $anchor [ 0 ] ;
393397 closeDropdown ( ) ;
394- return ;
398+ if ( sameAnchor ) {
399+ return ;
400+ }
395401 }
396402
397403 Menus . closeAll ( ) ;
398404
399405 Git . getBranches ( ) . catch ( function ( err ) {
400406 ErrorHandler . showError ( err , Strings . ERROR_GETTING_BRANCH_LIST ) ;
401407 } ) . then ( function ( branches = [ ] ) {
408+ if ( $dropdown ) {
409+ return ;
410+ }
402411 branches = branches . reduce ( function ( arr , branch ) {
403412 if ( ! branch . currentBranch && ! branch . remote ) {
404413 arr . push ( branch . name ) ;
@@ -407,6 +416,7 @@ define(function (require, exports) {
407416 } , [ ] ) ;
408417
409418 $dropdown = $ ( renderList ( branches ) ) ;
419+ $dropdownAnchor = $anchor ;
410420 if ( $anchor . closest ( "#git-panel" ) . length ) {
411421 // the git panel sits at the bottom of the screen, open upwards from there
412422 _positionDropdownAbove ( $anchor ) ;
0 commit comments