melissa/settings+ajuda: fechar ao clicar fora
Popover Personalizar (cog) e drawer de Ajuda agora fecham quando o user clica em qualquer lugar fora do panel. Listener mousedown em capture, watch em open pra anexar/desanexar; ignora o proprio botao trigger (data-ajuda-toggle pro ajuda; cogBtnEl ref pro settings) pra nao fazer close+reopen. Tambem flipa o panel do settings de top-12 pra bottom-12 (cog agora vive no bottom da .melissa-tray). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -15,7 +15,7 @@
|
|||||||
|--------------------------------------------------------------------------
|
|--------------------------------------------------------------------------
|
||||||
-->
|
-->
|
||||||
<script setup>
|
<script setup>
|
||||||
import { ref, computed } from 'vue';
|
import { ref, computed, watch, onBeforeUnmount } from 'vue';
|
||||||
import { useRoute, useRouter } from 'vue-router';
|
import { useRoute, useRouter } from 'vue-router';
|
||||||
import { useAjuda } from '@/composables/useAjuda';
|
import { useAjuda } from '@/composables/useAjuda';
|
||||||
|
|
||||||
@@ -73,6 +73,24 @@ function fechar() {
|
|||||||
faqAbertos.value = {};
|
faqAbertos.value = {};
|
||||||
closeDrawer();
|
closeDrawer();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ── Fechar ao clicar fora ─────────────────────────────────────
|
||||||
|
// Listener so existe enquanto o drawer esta aberto. Clique nos botoes
|
||||||
|
// que abrem/fecham o drawer (marcados com data-ajuda-toggle) sao
|
||||||
|
// ignorados — senao fecha aqui e o @click reabre.
|
||||||
|
function onDocMouseDown(e) {
|
||||||
|
if (!drawerOpen.value) return;
|
||||||
|
const t = e.target;
|
||||||
|
if (!(t instanceof Element)) return;
|
||||||
|
if (t.closest('.ajuda-panel')) return; // dentro do drawer
|
||||||
|
if (t.closest('[data-ajuda-toggle]')) return; // botao trigger
|
||||||
|
closeDrawer();
|
||||||
|
}
|
||||||
|
watch(drawerOpen, (open) => {
|
||||||
|
if (open) document.addEventListener('mousedown', onDocMouseDown, true);
|
||||||
|
else document.removeEventListener('mousedown', onDocMouseDown, true);
|
||||||
|
});
|
||||||
|
onBeforeUnmount(() => document.removeEventListener('mousedown', onDocMouseDown, true));
|
||||||
// ── Highlight de elemento na página ──────────────────────────
|
// ── Highlight de elemento na página ──────────────────────────
|
||||||
async function handleDocClick(e) {
|
async function handleDocClick(e) {
|
||||||
const anchor = e.target.closest('a[data-highlight]');
|
const anchor = e.target.closest('a[data-highlight]');
|
||||||
|
|||||||
@@ -620,8 +620,9 @@ onMounted(async () => {
|
|||||||
<NotificationDrawer />
|
<NotificationDrawer />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Ajuda -->
|
<!-- Ajuda — data-ajuda-toggle ignora este botao no
|
||||||
<button type="button" class="rail-topbar__btn" :class="{ 'rail-topbar__btn--active': ajudaDrawerOpen }" :title="ajudaDrawerOpen ? 'Fechar ajuda' : 'Ajuda'" @click="toggleAjuda">
|
click-outside do AjudaDrawer (senao fecha + reabre). -->
|
||||||
|
<button type="button" class="rail-topbar__btn" :class="{ 'rail-topbar__btn--active': ajudaDrawerOpen }" :title="ajudaDrawerOpen ? 'Fechar ajuda' : 'Ajuda'" data-ajuda-toggle @click="toggleAjuda">
|
||||||
<i class="pi pi-question-circle" />
|
<i class="pi pi-question-circle" />
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
|
|||||||
@@ -125,7 +125,7 @@ function onClearBg() {
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div class="glass-panel mp-panel absolute top-12 right-0 w-72">
|
<div class="glass-panel mp-panel absolute bottom-12 right-0 w-72">
|
||||||
<!-- Cabecalho fixo -->
|
<!-- Cabecalho fixo -->
|
||||||
<header class="mp-head">
|
<header class="mp-head">
|
||||||
<div class="mp-head__title">
|
<div class="mp-head__title">
|
||||||
|
|||||||
Reference in New Issue
Block a user