From 21df79e56811b976a683e4b61f6df52917c61e8c Mon Sep 17 00:00:00 2001 From: Vasilica Olariu Date: Wed, 17 Sep 2025 09:17:49 +0300 Subject: [PATCH 1/4] Update url for blogs --- src/lib/config/nav-menu/all-nav-items.config.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/config/nav-menu/all-nav-items.config.ts b/src/lib/config/nav-menu/all-nav-items.config.ts index 825e78f..ee6eceb 100644 --- a/src/lib/config/nav-menu/all-nav-items.config.ts +++ b/src/lib/config/nav-menu/all-nav-items.config.ts @@ -97,7 +97,7 @@ export const allNavItems: {[key: string]: NavMenuItem} = { }, blog: { label: 'Blog', - url: getMarketingUrl('/blog/all-posts'), + url: getMarketingUrl('/blogs'), }, bookADemo: { label: 'Book a Demo', From f406a6ac71e2bfbe1ff67f8bcd25394ec640dd4c Mon Sep 17 00:00:00 2001 From: Vasilica Olariu Date: Wed, 17 Sep 2025 12:32:30 +0300 Subject: [PATCH 2/4] PM-1947 - update url for blog --- src/lib/config/nav-menu/all-nav-items.config.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/config/nav-menu/all-nav-items.config.ts b/src/lib/config/nav-menu/all-nav-items.config.ts index ee6eceb..0c47f62 100644 --- a/src/lib/config/nav-menu/all-nav-items.config.ts +++ b/src/lib/config/nav-menu/all-nav-items.config.ts @@ -97,7 +97,7 @@ export const allNavItems: {[key: string]: NavMenuItem} = { }, blog: { label: 'Blog', - url: getMarketingUrl('/blogs'), + url: getMarketingUrl('/blog'), }, bookADemo: { label: 'Book a Demo', From 0a9f3f7469cec1b0f0c22789c28ba584bca8bb2d Mon Sep 17 00:00:00 2001 From: Vasilica Olariu Date: Wed, 17 Sep 2025 15:49:02 +0300 Subject: [PATCH 3/4] Add new method: destroy() --- src/main.ts | 23 ++++++++++++++++++++++- types/src/main.d.ts | 2 +- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/src/main.ts b/src/main.ts index 4141e8a..db62181 100644 --- a/src/main.ts +++ b/src/main.ts @@ -38,7 +38,7 @@ export type NavigationAppProps = { integrations?: {[key: string]: 'disable'} } -export type TcUniNavMethods = 'init' | 'update' | 'triggerFlow' +export type TcUniNavMethods = 'init' | 'update' | 'destroy' | 'triggerFlow' export type TcUniNavFn = ( method: TcUniNavMethods, @@ -54,6 +54,23 @@ const NavigationLoadersMap = { const instancesContextStore: { [key: string]: Map> } = {} +async function destroy( + targetId: string, +) { + if (typeof targetId !== 'string') { + throw new Error(`'targetId' should be a string`); + } + + const targetEl: Element | null = document.getElementById(targetId); + + if (targetEl?.nodeType !== Node.ELEMENT_NODE) { + throw new Error(`[TcUnivNav] 'target' must be a valid dom element with an id of #${targetId}!`); + } + + targetEl.innerHTML = ''; + delete instancesContextStore[targetId]; +} + /** * Initialize the navigation component * @param targetId Target element ID @@ -161,6 +178,10 @@ function execQueueCall(method: TcUniNavMethods, ...args: any[]) { triggerFlow.call(null, ...args) } + else if (method === 'destroy') { + destroy.call(null, ...args); + } + else if (method === 'trigger') { appPubSub.publish.call(appPubSub, ...args); } diff --git a/types/src/main.d.ts b/types/src/main.d.ts index dda39c0..cf0a307 100644 --- a/types/src/main.d.ts +++ b/types/src/main.d.ts @@ -21,5 +21,5 @@ export declare type NavigationAppProps = { [key: string]: 'disable'; }; }; -export declare type TcUniNavMethods = 'init' | 'update' | 'triggerFlow'; +export declare type TcUniNavMethods = 'init' | 'update' | 'destroy' | 'triggerFlow'; export declare type TcUniNavFn = (method: TcUniNavMethods, targetId: string, config: NavigationAppProps) => void; From 774cc3d3c233f8a4eb83f8ef31e871e65f3d90e6 Mon Sep 17 00:00:00 2001 From: Vasilica Olariu Date: Wed, 17 Sep 2025 15:52:43 +0300 Subject: [PATCH 4/4] safe check & delete instance --- src/main.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/main.ts b/src/main.ts index db62181..332f496 100644 --- a/src/main.ts +++ b/src/main.ts @@ -57,6 +57,10 @@ const instancesContextStore: { [key: string]: Map> } = {} async function destroy( targetId: string, ) { + if (Object.prototype.hasOwnProperty.call(instancesContextStore, targetId)) { + delete instancesContextStore[targetId]; + } + if (typeof targetId !== 'string') { throw new Error(`'targetId' should be a string`); } @@ -68,7 +72,6 @@ async function destroy( } targetEl.innerHTML = ''; - delete instancesContextStore[targetId]; } /**