Skip default behaviour if we are clicking a result for the same location

This commit is contained in:
Alfredo Sumaran 2016-03-31 15:28:45 -05:00
parent ccc929d75d
commit e3a9830507
2 changed files with 9 additions and 1 deletions

View file

@ -174,7 +174,7 @@ class GitLabDropdown
selected = self.rowClicked $(@)
if self.options.clicked
self.options.clicked(selected)
self.options.clicked(selected, e)
# Finds an element inside wrapper element
getElement: (selector) ->

View file

@ -62,6 +62,8 @@ class @SearchAutocomplete
search:
fields: ['text']
data: @getData.bind(@)
selectable: true
clicked: @onClick.bind(@)
getData: (term, callback) ->
_this = @
@ -268,3 +270,9 @@ class @SearchAutocomplete
<li><a class='dropdown-menu-empty-link is-focused'>Loading...</a></li>
</ul>"
@dropdownContent.html(html)
onClick: (item, e) ->
if location.pathname.indexOf(item.url) isnt -1
e.preventDefault()
@disableAutocomplete()
@searchInput.val('')