Skip to main content

foundation-header.navigation.onbeforenavbuttonclick

Home > @genesislcap/foundation-header > Navigation > onBeforeNavButtonClick

Callback invoked before navigation occurs when a nav button is clicked. Awaited before the route changes, so async cleanup is supported.

Signature:

onBeforeNavButtonClick?: (detail: NavButtonClickDetail) => void | Promise<void>;

Remarks​

DOM events cannot be awaited, so this callback is the only way to guarantee execution before the route changes. The nav-button-clicked event fires after navigation and is suitable for informational use only.

Example​

<foundation-header
:onBeforeNavButtonClick=${(x) => async (detail) => {
await x.cleanup();
console.log(`Navigating from ${detail.oldPath} to ${detail.newPath}`);
}}
/>