Skip to content

Commit 18bc3a7

Browse files
author
vikasrohit
committed
AS#113534192025965, Autofill the search term, from query string, in SearchBar
-- Fixing lint errors
1 parent 37661f5 commit 18bc3a7

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

components/SearchBar/SearchBar.jsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@ import classNames from 'classnames'
1111
class SearchBar extends Component {
1212
constructor(props) {
1313
super(props)
14-
const searchValue = this.getQueryStringValue(props.searchTermKey)
14+
const initialTerm = this.getQueryStringValue(props.searchTermKey)
1515
this.state = {
1616
searchState: searchValue.length > 0 ? 'filled' : 'empty',
1717
suggestions: [],
18-
searchValue: searchValue
18+
searchValue: initialTerm
1919
}
2020
this.onFocus = this.onFocus.bind(this)
2121
this.onChange = this.onChange.bind(this)
@@ -28,7 +28,7 @@ class SearchBar extends Component {
2828
}
2929

3030
getQueryStringValue (key) {
31-
return unescape(window.location.href.replace(new RegExp("^(?:.*[&\\?]" + escape(key).replace(/[\.\+\*]/g, "\\$&") + "(?:\\=([^&]*))?)?.*$", "i"), "$1"));
31+
return unescape(window.location.href.replace(new RegExp('^(?:.*[&\\?]' + escape(key).replace(/[\.\+\*]/g, '\\$&') + '(?:\\=([^&]*))?)?.*$', 'i'), '$1'))
3232
}
3333

3434
componentDidMount() {
@@ -81,7 +81,7 @@ class SearchBar extends Component {
8181
searchValue: this.refs.searchValue.value,
8282
requestNo: rc,
8383
maxRequestNo: rc,
84-
loading: newTerm.length > 0 ? true : false,
84+
loading: newTerm.length > 0,
8585
searchState: 'focused'
8686
}
8787
},

0 commit comments

Comments
 (0)