Skip to content

Commit

Permalink
fix checcked item appearing above all option on initial render
Browse files Browse the repository at this point in the history
  • Loading branch information
CollinBeczak committed Jan 24, 2024
1 parent 992105b commit 914a46c
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/components/AutosuggestTextBox/AutosuggestTextBox.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,11 +143,13 @@ export default class AutosuggestTextBox extends Component {
const preferredResults = this.getPreferredResults()

const reorderedSearchResults = searchResults.sort((a, b) => {
if(a.id === FILTER_SEARCH_ALL || a.name === this.props.inputValue) return -1
if(b.id === FILTER_SEARCH_ALL || b.name === this.props.inputValue) return 1
if (a.id === FILTER_SEARCH_ALL) return -1
if (b.id === FILTER_SEARCH_ALL) return 1
if (a.name === this.props.inputValue) return -1
if (b.name === this.props.inputValue) return 1
return isChecked(b) - isChecked(a)
})

if (!_isEmpty(preferredResults)) {
let className = "mr-font-medium"
items = items.concat(_map(reorderedSearchResults,
Expand Down

0 comments on commit 914a46c

Please sign in to comment.