Commit 5f4ce722 authored by Alfredo Sumaran's avatar Alfredo Sumaran

Display clear button only if input has a value

parent ee87d15c
...@@ -142,7 +142,7 @@ class @SearchAutocomplete ...@@ -142,7 +142,7 @@ class @SearchAutocomplete
@searchInput.on 'keyup', @onSearchInputKeyUp @searchInput.on 'keyup', @onSearchInputKeyUp
@searchInput.on 'click', @onSearchInputClick @searchInput.on 'click', @onSearchInputClick
@searchInput.on 'focus', @onSearchInputFocus @searchInput.on 'focus', @onSearchInputFocus
@clearInput.on 'click', @onRemoveLocationClick @clearInput.on 'click', @onClearInputClick
onDocumentClick: (e) => onDocumentClick: (e) =>
if not $.contains(@dropdown[0], e.target) and @isFocused if not $.contains(@dropdown[0], e.target) and @isFocused
...@@ -189,6 +189,8 @@ class @SearchAutocomplete ...@@ -189,6 +189,8 @@ class @SearchAutocomplete
# We should display the menu only when input is not empty # We should display the menu only when input is not empty
@enableAutocomplete() @enableAutocomplete()
@wrap.toggleClass 'has-value', !!e.target.value
# Avoid falsy value to be returned # Avoid falsy value to be returned
return return
...@@ -200,9 +202,8 @@ class @SearchAutocomplete ...@@ -200,9 +202,8 @@ class @SearchAutocomplete
@isFocused = true @isFocused = true
@wrap.addClass('search-active') @wrap.addClass('search-active')
onRemoveLocationClick: (e) => onClearInputClick: (e) =>
e.preventDefault() e.preventDefault()
@removeLocationBadge()
@searchInput.val('').focus() @searchInput.val('').focus()
onSearchInputBlur: (e) => onSearchInputBlur: (e) =>
......
...@@ -144,16 +144,16 @@ ...@@ -144,16 +144,16 @@
color: $location-icon-active-color; color: $location-icon-active-color;
} }
} }
}
&.has-location-badge { &.has-value {
.search-icon { .search-icon {
display: none; display: none;
} }
.clear-icon { .clear-icon {
cursor: pointer; cursor: pointer;
display: block; display: block;
}
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment