Skip to content

Commit

Permalink
fix(rerendering): fixed unnecessary rerendering
Browse files Browse the repository at this point in the history
* when input was clicked, list would rerender. Now checking that what you clicked is input and not rerendering.

From #32 #33
  • Loading branch information
darrenjennings authored Mar 26, 2018
1 parent 5469898 commit 920c885
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/Autosuggest.vue
Original file line number Diff line number Diff line change
Expand Up @@ -348,13 +348,19 @@ export default {
updateCurrentIndex(index) {
this.currentIndex = index;
},
onDocumentMouseUp() {
onDocumentMouseUp(e) {
/** Clicks outside of dropdown to exit */
if (this.currentIndex === null || !this.isOpen) {
this.loading = this.shouldRenderSuggestions();
return;
}
/** Do not re-render list on input click */
const isChild = this.$el.contains(e.target);
if (isChild && e.target.tagName === 'INPUT') {
return;
}
/** Selects an item in the dropdown */
this.loading = true;
this.didSelectFromOptions = true;
Expand Down

0 comments on commit 920c885

Please sign in to comment.