Created
December 6, 2022 17:35
-
-
Save IlCallo/07e64961118278fde36204512485cff2 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { | |
addEscapeKey, | |
removeEscapeKey, | |
} from 'quasar/src/utils/private/escape-key.js'; | |
import { onMounted, onUnmounted } from 'vue'; | |
// Quasar doesn't offer a way to hook into the esc handler from inside the dialog component itself, | |
// so we have to do it ourselves | |
// This requires the QDialog to have `no-esc-dismiss` and `no-shake` (purely aesthetic) prop enabled | |
export function useDialogEscapeKey( | |
handler: (event: Event) => void | Promise<void>, | |
) { | |
onMounted(() => { | |
addEscapeKey(handler); | |
}); | |
onUnmounted(() => { | |
removeEscapeKey(handler); | |
}); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
declare module 'quasar/src/utils/private/escape-key.js' { | |
export function addEscapeKey( | |
handler: (event: Event) => void | Promise<void>, | |
): void; | |
export function removeEscapeKey( | |
handler: (event: Event) => void | Promise<void>, | |
): void; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment