]> BookStack Code Mirror - bookstack/blobdiff - resources/js/components/dropdown-search.js
Opensearch: Fixed XML declaration when php short tags enabled
[bookstack] / resources / js / components / dropdown-search.js
index 8c81aae3c2b338bfb1a49723383e603952e1d878..fcbabc022a7c21395272c092e175fb968d773ab2 100644 (file)
@@ -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