X-Git-Url: http://source.bookstackapp.com/bookstack/blobdiff_plain/a6633642232efd164d4708967ab59e498fbff896..refs/pull/5415/head:/resources/js/components/dropdown-search.js diff --git a/resources/js/components/dropdown-search.js b/resources/js/components/dropdown-search.js index 8c81aae3c..fcbabc022 100644 --- a/resources/js/components/dropdown-search.js +++ b/resources/js/components/dropdown-search.js @@ -1,6 +1,8 @@ -import {debounce} from "../services/util"; +import {debounce} from '../services/util.ts'; +import {transitionHeight} from '../services/animations.ts'; +import {Component} from './component'; -class DropdownSearch { +export class DropdownSearch extends Component { setup() { this.elem = this.$el; @@ -27,6 +29,7 @@ class DropdownSearch { this.runLocalSearch(input); } else { this.toggleLoading(true); + this.listContainerElem.innerHTML = ''; this.runAjaxSearch(input); } } @@ -37,7 +40,7 @@ class DropdownSearch { runLocalSearch(searchTerm) { const listItems = this.listContainerElem.querySelectorAll(this.localSearchSelector); - for (let listItem of listItems) { + for (const listItem of listItems) { const match = !searchTerm || listItem.textContent.toLowerCase().includes(searchTerm); listItem.style.display = match ? 'flex' : 'none'; listItem.classList.toggle('hidden', !match); @@ -50,7 +53,9 @@ class DropdownSearch { try { const resp = await window.$http.get(this.getAjaxUrl(searchTerm)); + const animate = transitionHeight(this.listContainerElem, 80); this.listContainerElem.innerHTML = resp.data; + animate(); } catch (err) { console.error(err); } @@ -75,5 +80,3 @@ class DropdownSearch { } } - -export default DropdownSearch; \ No newline at end of file