Skip to content

Commit

Permalink
reworked text input handling
Browse files Browse the repository at this point in the history
  • Loading branch information
simonseyock committed Jan 11, 2019
1 parent 37e1db2 commit 5a43798
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/SearchControl.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import { keyCodes } from 'guide4you/src/globals'
import { html2Text } from 'guide4you/src/utilities'
import { Control } from 'guide4you/src/controls/Control'
import { SearchView } from './SearchView'
import { filterText } from 'guide4you/src/xssprotection'

import 'polyfill!Element.prototype.placeholder'

Expand Down Expand Up @@ -333,7 +334,7 @@ export class SearchControl extends Control {
clearTimeout(this.autocompleteTimeout_)
this.autocompleteTimeout_ = setTimeout(() => {
// checking if autocomplete search should be performed and perform it
let searchtext = encodeURIComponent(this.$textfield_.val())
let searchtext = this.$textfield_.val()
if (this.autocompleteStart_ >= 0 && searchtext.length >= this.autocompleteStart_) {
this.searchConnector_.getAutoComplete(searchtext)
.then(([dropdownTexts, data]) => {
Expand All @@ -352,7 +353,6 @@ export class SearchControl extends Control {
let searchstring = this.$textfield_.val()

if (!this.dropdown_.getValue() || searchstring !== html2Text(this.dropdown_.getText())) {
searchstring = encodeURIComponent(searchstring)
this.searchView_.hideSearchResults()

if (searchstring !== '') {
Expand Down Expand Up @@ -392,24 +392,24 @@ export class SearchControl extends Control {
this.dispatchEvent({
type: 'searchEnd',
success: true,
searchTerm: this.getSearchValue()
searchTerm: this.getSanitizedSearchValue()
})
} else {
this.dropdown_.showGhostEntry()

this.dispatchEvent({
type: 'searchEnd',
success: false,
searchTerm: this.getSearchValue()
searchTerm: this.getSanitizedSearchValue()
})
}
}

/**
* @returns {string}
*/
getSearchValue () {
return encodeURIComponent(this.$textfield_.val())
getSanitizedSearchValue () {
return filterText(this.$textfield_.val())
}

/**
Expand Down

0 comments on commit 5a43798

Please sign in to comment.