From 920c885953e2ceba2c64f70c565c707654749044 Mon Sep 17 00:00:00 2001 From: Darren Jennings Date: Mon, 26 Mar 2018 14:36:40 -0700 Subject: [PATCH] fix(rerendering): fixed unnecessary rerendering * when input was clicked, list would rerender. Now checking that what you clicked is input and not rerendering. From #32 #33 --- src/Autosuggest.vue | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/Autosuggest.vue b/src/Autosuggest.vue index 31b71c3..571f709 100644 --- a/src/Autosuggest.vue +++ b/src/Autosuggest.vue @@ -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;