Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions packages/vue/src/hooks/back-button.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import type { BackButtonEvent } from "@ionic/core/components";
import { onBeforeUnmount, getCurrentInstance } from 'vue'

type Handler = (processNextHandler: () => void) => Promise<any> | void | null;
export interface UseBackButtonResult {
Expand All @@ -15,6 +16,12 @@ export const useBackButton = (
document.removeEventListener("ionBackButton", callback);

document.addEventListener("ionBackButton", callback);

if (getCurrentInstance()){
onBeforeUnmount(() => {
unregister()
});
}

return { unregister };
};
8 changes: 7 additions & 1 deletion packages/vue/src/hooks/keyboard.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { Ref } from "vue";
import { ref } from "vue";
import { ref, onBeforeUnmount, getCurrentInstance } from "vue";

export interface UseKeyboardResult {
isOpen: Ref<boolean>;
Expand Down Expand Up @@ -33,6 +33,12 @@ export const useKeyboard = (): UseKeyboardResult => {
window.addEventListener("ionKeyboardDidHide", hideCallback);
}

if (getCurrentInstance()){
onBeforeUnmount(() => {
unregister()
});
}

return {
isOpen,
keyboardHeight,
Expand Down
Loading