From fa5677200988578f77f388763183d5b1bcad3524 Mon Sep 17 00:00:00 2001 From: Jon Johnson Date: Tue, 27 Aug 2024 12:06:12 -0700 Subject: [PATCH] Protected Against Empty transition.to (#386) When a transition is aborted (and maybe at other times) transition.to is null and needs to be guarded against just like transition.from. --- addon/components/navigation-narrator.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/addon/components/navigation-narrator.js b/addon/components/navigation-narrator.js index 363683a..d9a9528 100644 --- a/addon/components/navigation-narrator.js +++ b/addon/components/navigation-narrator.js @@ -82,7 +82,7 @@ export default class NavigationNarratorComponent extends Component { get hasQueryParams() { if ( Object.keys(this.transition.from?.queryParams || {}).length || - Object.keys(this.transition.to.queryParams).length > 0 + Object.keys(this.transition.to?.queryParams || {}).length > 0 ) { return true; } else { @@ -108,7 +108,7 @@ export default class NavigationNarratorComponent extends Component { this.transition = transition; // We need to do this because we can't pass an argument to a getter // add a check to see if it's the same route - let hasSameRoute = this.transition.from?.name === this.transition.to.name; + let hasSameRoute = this.transition.from?.name === this.transition.to?.name; if (this.excludeAllQueryParams && this.hasQueryParams && hasSameRoute) { return;