     ).disableSelection()
 
   bindMergeRequestSorting: ->
+    $('a[data-toggle="tab"]').on 'show.bs.tab', (e) ->
+      currentTabClass  = $(e.target).data('show')
+      previousTabClass =  $(e.relatedTarget).data('show')
+
+      $(previousTabClass).hide()
+      $(currentTabClass).removeClass('hidden')
+      $(currentTabClass).show()
+      
     $("#merge_requests-list-unassigned, #merge_requests-list-ongoing, #merge_requests-list-closed").sortable(
       connectWith: ".merge_requests-sortable-list",
       dropOnEmpty: true,
       items: "li:not(.ui-sort-disabled)",
+      beforeStart: (event, ui) ->
+        $(".merge_requests-sortable-list").css "min-height", ui.item.outerHeight()
+      stop: (event, ui) ->
+        $(".merge_requests-sortable-list").css "min-height", "0px"
       update: (event, ui) ->
         data = $(this).sortable("serialize")
         Milestone.sortMergeRequests(data)

      dataType: "json"

  constructor: ->
    @bindIssuesSorting()
    @bindMergeRequestSorting()
    @bindTabsSwitching

        Milestone.updateMergeRequest(ui.item, merge_request_url, data)

    ).disableSelection()
