diff --git a/flightkit/components/tree-navigation.js b/flightkit/components/tree-navigation.js index d21c52a..4e8ae44 100644 --- a/flightkit/components/tree-navigation.js +++ b/flightkit/components/tree-navigation.js @@ -230,13 +230,15 @@ export class FlightkitTreeNavigation extends HTMLElement { } } - resetTree() { + resetTree(all = true) { let foundElements = this.querySelectorAll('[data-branch-values]'); for (const element of foundElements) { element.parentElement.style.opacity = ''; element.parentElement.classList.remove('hidden'); - element.removeAttribute('open'); + if (all) { + element.removeAttribute('open'); + } } } @@ -250,6 +252,11 @@ export class FlightkitTreeNavigation extends HTMLElement { element.removeAttribute('open'); } + clearFilter() { + this.resetTree(false); + this.filter = { value: '', caseSensitive: false }; + } + filterTree() { let searchTimer = setTimeout(() => { let foundElements = this.querySelectorAll('[data-branch-values]'); diff --git a/flightkit/index.html b/flightkit/index.html index dcf4a25..3aa0cec 100644 --- a/flightkit/index.html +++ b/flightkit/index.html @@ -16,10 +16,6 @@ code { width: fit-content; } - - #search { - width: 100%; - } @@ -35,9 +31,11 @@ + - +
@@ -103,6 +101,11 @@ myDbNav.deselectTree(); }) + document.getElementById('clearSearch').addEventListener('click', () => { + myDbNav.clearFilter(); + document.getElementById('search').value = "" + }) + document.getElementById('toggleSearch').addEventListener('click', () => { const style = myDbNav.getAttribute('search-style'); if (!style || style === null) {