client: collapse search on click outside

This commit is contained in:
geoffrey45
2021-12-31 12:53:10 +03:00
parent 61e7ff7188
commit d74aee0c46
3 changed files with 21 additions and 12 deletions
+16 -6
View File
@@ -86,7 +86,7 @@
<script>
import { ref, toRefs } from "@vue/reactivity";
import { watch } from "@vue/runtime-core";
import { onMounted, watch } from "@vue/runtime-core";
import state from "@/composables/state.js";
export default {
@@ -125,6 +125,10 @@ export default {
title: "📁 Folder",
icon: "📁",
},
{
title: "🈁 Here",
icon: "🈁",
}
];
const searchComponent = ref(null);
const filters = ref(state.filters);
@@ -189,18 +193,24 @@ export default {
}
});
function hideScrollable() {
document.querySelector(".scrollable").classList.remove("v1");
document.querySelector(".scrollable").classList.add("v0");
}
onMounted(() => {
const dom = document.getElementsByClassName("right-search")[0]
document.addEventListener("click", (e) => {
var isClickedInside = dom.contains(e.target);
if (!isClickedInside) {
emit("collapseSearch");
}
});
});
return {
addFilter,
activateMagicFlag,
removeMagicFlag,
removeFilter,
removeLastFilter,
hideScrollable,
songs,
albums,
artists,