From 4f43cf41720843c607daa5a56eec5db9d691e5e3 Mon Sep 17 00:00:00 2001 From: Suresh Kumar Gangumalla Date: Mon, 22 Apr 2024 14:40:58 +0530 Subject: [PATCH] Remove event listeners of previous route component Removing event listeners of previous route component before creating target(next) route component instance. Signed-off-by: Suresh Kumar Gangumalla --- src/router/router.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/router/router.js b/src/router/router.js index e097417c..c77a29e7 100644 --- a/src/router/router.js +++ b/src/router/router.js @@ -22,6 +22,7 @@ import { Log } from '../lib/log.js' import { stage } from '../launch.js' import Focus from '../focus.js' import Announcer from '../announcer/announcer.js' +import eventListeners from '../lib/eventListeners.js' export let currentRoute export let navigating = false @@ -143,6 +144,11 @@ export const navigate = async function () { route.transition = route.transition(previousRoute, route) } + // remove event listeners from current active view + if (previousRoute) { + eventListeners.removeListeners(this.activeView) + } + let holder let { view, focus } = cacheMap.get(route) || {}