Always display suggestions

This commit is contained in:
Alfredo Sumaran 2016-03-26 16:52:16 -05:00
parent 47405485f6
commit 55afebe141
3 changed files with 20 additions and 25 deletions

View file

@ -72,9 +72,6 @@ class @SearchAutocomplete
# Prevent multiple ajax calls
return if @loadingSuggestions
# Do not request suggestions if dropdown is disabled
return if @badgePresent()
@loadingSuggestions = true
jqXHR = $.get(@autocompletePath, {
@ -132,16 +129,12 @@ class @SearchAutocomplete
# No need to enable anything if user is not logged in
return if !gon.current_user_id
dropdownMenu = @dropdown.find('.dropdown-menu')
_this = @
@loadingSuggestions = false
@dropdown.addClass('open')
@searchInput.removeClass('disabled')
onDropdownOpen: (e) =>
@dropdown.dropdown('toggle')
onSearchInputKeyDown: =>
# Saves last length of the entered text
@saveTextLength()
@ -154,23 +147,20 @@ class @SearchAutocomplete
@removeLocationBadge()
# When removing the last character and no badge is present
if @lastTextLength is 1 and !@badgePresent()
if @lastTextLength is 1
@disableAutocomplete()
# When removing any character from existin value
if @lastTextLength > 1
@enableAutocomplete()
when KEYCODE.ESCAPE
if @badgePresent()
else
@restoreOriginalState()
@restoreOriginalState()
# If after restoring there's a badge
@disableAutocomplete() if @badgePresent()
else
if @badgePresent()
@disableAutocomplete()
else
# We should display the menu only when input is not empty
if @searchInput.val() isnt ''
@enableAutocomplete()
# We should display the menu only when input is not empty
if @searchInput.val() isnt ''
@enableAutocomplete()
# Avoid falsy value to be returned
return
@ -229,8 +219,8 @@ class @SearchAutocomplete
@dropdown.removeClass 'open'
# Only add class if there's a badge
if @badgePresent()
@searchInput.addClass 'disabled'
# if @badgePresent()
# @searchInput.addClass 'disabled'
badgePresent: ->
@locationBadgeEl.children().length

View file

@ -205,5 +205,5 @@ $search-input-width: $dropdown-width;
$location-badge-color: #aaa;
$location-badge-bg: $gray-normal;
$location-icon-color: #e7e9ed;
$location-active-color: #7f8fa4;
$location-active-bg: $location-active-color;
$location-active-color: $gl-text-color;
$location-active-bg: $search-input-border-color;

View file

@ -63,6 +63,7 @@
.search-input-container {
display: -webkit-flex;
display: flex;
position: relative;
}
.search-location-badge, .search-input-wrap {
@ -72,7 +73,6 @@
.search-input-wrap {
width: 100%;
position: relative;
.search-icon, .clear-icon {
position: absolute;
@ -100,6 +100,11 @@
display: none;
}
// Rewrite position. Dropdown menu should be relative to .search-input-container
.dropdown {
position: static;
}
.dropdown-header {
text-transform: uppercase;
font-size: 11px;