From cb6a7ecab05fc7ab4f2db1029fbe7556df4b96e7 Mon Sep 17 00:00:00 2001 From: Sean Perkins Date: Wed, 30 Aug 2023 23:59:25 -0400 Subject: [PATCH] fix(nav-link): prevent navigation when clicking disabled button --- core/src/components/nav-link/nav-link.tsx | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/core/src/components/nav-link/nav-link.tsx b/core/src/components/nav-link/nav-link.tsx index db5ba4a5b2..e0527c23cd 100644 --- a/core/src/components/nav-link/nav-link.tsx +++ b/core/src/components/nav-link/nav-link.tsx @@ -34,7 +34,14 @@ export class NavLink implements ComponentInterface { @Prop() routerAnimation?: AnimationBuilder; private onClick = () => { - return navLink(this.el, this.routerDirection, this.component, this.componentProps, this.routerAnimation); + const { el } = this; + const button = el.querySelector('button,ion-button,a'); + if (button?.hasAttribute('disabled')) { + // Do not navigate if the button is disabled + return; + } + + return navLink(el, this.routerDirection, this.component, this.componentProps, this.routerAnimation); }; render() {