From f91df20dc10e7f1da32be8c43021375d71abd0a0 Mon Sep 17 00:00:00 2001 From: Jesse Wierzbinski Date: Tue, 4 Jun 2024 18:44:12 -1000 Subject: [PATCH] fix: :bug: Fix AdaptiveDropdown not responding to touch on mobile --- components/composer/modal.client.vue | 1 - components/dropdowns/AdaptiveDropdown.vue | 66 +++++++++++++++++------ components/sidebars/navigation.vue | 39 +++++++------- 3 files changed, 67 insertions(+), 39 deletions(-) diff --git a/components/composer/modal.client.vue b/components/composer/modal.client.vue index 2eee53b..2e307a7 100644 --- a/components/composer/modal.client.vue +++ b/components/composer/modal.client.vue @@ -46,7 +46,6 @@ useListen("composer:open", () => { useListen("composer:close", () => { open.value = false; }); -const log = console.log; const tokenData = useTokenData(); const instance = useInstance(); \ No newline at end of file diff --git a/components/dropdowns/AdaptiveDropdown.vue b/components/dropdowns/AdaptiveDropdown.vue index ae14597..8e62a46 100644 --- a/components/dropdowns/AdaptiveDropdown.vue +++ b/components/dropdowns/AdaptiveDropdown.vue @@ -5,23 +5,27 @@ -
-
- - - -
-
-
- -
-
-
+ + +
+
+ + + +
+
+
+ +
+
+
+
@@ -31,4 +35,32 @@ const { width } = useWindowSize(); const isSmallScreen = computed(() => width.value < 768); const open = ref(false); +const id = useId(); + +// HACK: Fix the menu children not reacting to touch events as click for some reason +const registerClickHandlers = () => { + const targetElement = document.querySelector(`.${id}`); + if (targetElement) { + for (const el of targetElement.children) { + el.addEventListener("pointerdown", (e) => { + e.stopPropagation(); + e.preventDefault(); + // Click all element children + for (const elChild of Array.from(el.children)) { + if (elChild instanceof HTMLElement) { + elChild.click(); + } + } + }); + } + } +}; + +// When opening, register click handlers +watch(open, async (o) => { + if (o) { + await nextTick(); + registerClickHandlers(); + } +}); \ No newline at end of file diff --git a/components/sidebars/navigation.vue b/components/sidebars/navigation.vue index 5229b18..10a6bd8 100644 --- a/components/sidebars/navigation.vue +++ b/components/sidebars/navigation.vue @@ -106,27 +106,25 @@