-
-
Notifications
You must be signed in to change notification settings - Fork 7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Bug Report][3.3.19] Clicking close button of VSnackbar
opened after VDialog
closes the dialog too
#18384
Comments
The dialog will close on every click outside of it, you can use the persistent prop to alter that behavior. Demo |
See #17398 for why I am not currently using |
The problem has been resolved ? have any new update ? pls help me |
This also applies to datepickers. |
I ended up having to use
However I haven't figured out how to re-enable the browser back button closing the dialog |
I ran into this issue too and the only solution I found is to use the I don't like this solution. There should be a way to make the dialog aware of the snackbar and setting an exception for the outside click close. Composable: type Teleport = boolean | string | HTMLElement;
const useDialogAwareTeleport = (
teleportOverride?: MaybeRefOrGetter<Teleport | undefined>,
elementRef?: MaybeRefOrGetter<undefined | { $el: Node | null }>,
resetOnChange?: MaybeRefOrGetter,
dialogSelector: string = ".v-dialog > .v-overlay__content"
) => {
const dialogAwareTeleport = ref<Teleport>();
watchEffect(() => {
toValue(resetOnChange); // This makes sure the watcher is run on changes of resetOnChange refs
if (toValue(teleportOverride) !== undefined) {
dialogAwareTeleport.value = toValue(teleportOverride)
return;
}
const containingDialog = findContainingDialog();
dialogAwareTeleport.value = containingDialog ? containingDialog : true;
});
function findContainingDialog() {
const dialogs = document.querySelectorAll<HTMLElement>(dialogSelector);
if (dialogs.length === 0) return null;
const elementContainer = toValue(elementRef);
if (!elementContainer) return dialogs[0];
let containingDialog = null;
for (let i = 0; i < dialogs.length && containingDialog === null; i++) {
const dialog = dialogs[i];
if (dialog.contains(elementContainer.$el)) {
containingDialog = dialog;
}
}
return containingDialog;
}
return { dialogAwareTeleport };
};
export { useDialogAwareTeleport }; Usage (some business logic code left out): <template>
<v-snackbar
v-model="isOpen"
:timeout="-1"
multi-line
:attach="dialogAwareTeleport"
>
<span>{{snackbarText}}</span>
<template #actions>
<e-button
ref="closeButtonRef"
variant="text"
icon="mdi-close"
@click="closeSnackbar"
/>
</template>
</v-snackbar>
</template>
<script setup lang="ts">
const isOpen = ref(false);
const snackbarText = ref("");
const closeButtonRef = ref();
const snackbarIsVisible = useElementVisibility(closeButtonRef);
watch(snackbarIsVisible, (isVisible) => {
if (!isVisible && isOpen.value) closeSnackbar();
});
const { dialogAwareTeleport } = useDialogAwareTeleport(
undefined,
undefined,
snackbarText,
".v-dialog > .v-overlay__content"
);
</script> |
I think I've got a fix for this, will open a PR soon |
fixes vuetifyjs#18384 Don't close on click outside if using scrim and the click is on an element above the scrim.
fixes vuetifyjs#18384 Don't close on click outside if using scrim and the click is on an element above the scrim.
fixes vuetifyjs#18384 Don't close on click outside if using scrim and the click is on an element above the scrim.
fixes vuetifyjs#18384 Don't close on click outside if using scrim and the click is on an element above the scrim.
fixes #18384 Co-authored-by: John Leider <john@vuetifyjs.com>
vuetifyjs/vuetify#18384 has been fixed by a certain someone!
vuetifyjs/vuetify#18384 has been fixed by a certain someone!
Environment
Vuetify Version: 3.5.1
Last working version: 3.1.8
Vue Version: 3.4.15
Browsers: Edge 117.0.2045.47
OS: Windows 10
Steps to reproduce
v-snackbar
that opens after av-dialog
(e.g. showing an error message after submitting a form in the dialog).Expected Behavior
The snackbar closes.
Actual Behavior
Both the snackbar and the dialog close.
Reproduction Link
https://play.vuetifyjs.com/#...
Other comments
Probably related to the fix for #16893.
I tried using
@click.stop
in the snackbar's close button but that didn't do anything.This is a recreation of #17013 after that was closed as a duplicate of #7310 but then the latter was closed as only applying to v2
The text was updated successfully, but these errors were encountered: