-
Notifications
You must be signed in to change notification settings - Fork 66
Feature/forward arrow key autocomplete #81
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
a92615d
a7c219e
97c9087
0e6bedf
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -23,25 +23,32 @@ class SearchSuggestions extends Component { | |
| render() { | ||
| const recentList = this.props.recentSearch | ||
| const popularList = this.props.popularSearch | ||
|
|
||
| const suggestionItem = (term, i) => { | ||
| let labelDOM = term | ||
| const searchTerm = this.props.searchTerm | ||
| let exactMatch = false | ||
| if (searchTerm.length > 0) { | ||
| const idx = term.toLowerCase().indexOf(searchTerm.toLowerCase()) | ||
| if (idx !== -1) { | ||
| // check if exact match | ||
| exactMatch = idx === 0 && term.length === searchTerm.length | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would it ever be the case that
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nopes, because we are checking for index of |
||
| // prepare DOM for the content to be rendered under StandardListItem | ||
| labelDOM = ( | ||
| <span> | ||
| <span className={ itemClasses }> | ||
| { term.substring(0, idx) } | ||
| <strong>{ searchTerm }</strong> | ||
| { term.substring(idx + searchTerm.length) } | ||
| </span> | ||
| ) | ||
| } | ||
| } | ||
|
|
||
| // prepares css class for li | ||
| const itemClasses = classNames( | ||
| { selected : exactMatch } | ||
| ) | ||
| // prepares and returns the DOM for each popular/recent search item | ||
| return ( | ||
| <li key={ i } data-term={term} onClick={ this.handleClick }> | ||
| <li key={ i } data-term={term} onClick={ this.handleClick } className={ itemClasses }> | ||
| <StandardListItem labelText={ labelDOM } showIcon={ false } /> | ||
| </li> | ||
| ) | ||
|
|
@@ -105,13 +112,13 @@ class SearchSuggestions extends Component { | |
| SearchSuggestions.propTypes = { | ||
| onSuggestionSelect : PropTypes.func.isRequired, | ||
| recentSearch : PropTypes.array, | ||
| popularSearch : PropTypes.array, | ||
| popularSearch : PropTypes.array, | ||
| searchTerm : PropTypes.string | ||
| } | ||
|
|
||
| SearchSuggestions.defaultProps = { | ||
| recentSearch : [], | ||
| popularSearch : [], | ||
| popularSearch : [], | ||
| searchTerm : '' | ||
| } | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -68,6 +68,10 @@ | |
| padding: 0; | ||
| padding-bottom: 5px; | ||
|
|
||
| li.selected { | ||
| background-color: $gray-light; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I imagine Vic will want the nav when it's completely finished to include the new UI Kit colors / fonts, etc. We can check with him on the details.
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Okies. But managing the separate branch till we have UI kit complete, can be bit difficult because we have continuous updates in dev branch. Anyway, it sounds good to have finished nav out instead of unfinished one. |
||
| } | ||
|
|
||
| .StandardListItem { | ||
| align-items: initial; | ||
| text-align: left; | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think
const suggestion = this.state.suggestions[0]would work tooThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess yes because that would assign
undefinedif suggestions array does not have any element in it andif (suggestion)would not evaluate to true in both cases,undefinedandnullThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just to close the thread, change is done in dev.