@@ -71,9 +71,19 @@ const LinkItemContainerNoBox = React.forwardRef<HTMLAnchorElement, LinkItemConta
7171
7272 // Check if click is on a button/svg/path (menu trigger) and prevent navigation immediately
7373 const targetTag = ( event . target as HTMLElement ) ?. tagName ?. toLowerCase ( )
74- if ( [ 'button' , 'svg' , 'path' ] . includes ( targetTag ) ) {
75- console . log ( '[LinkItemContainerNoBox] Click on button/svg/path detected, preventing default' )
74+ const isMenuTrigger = [ 'button' , 'svg' , 'path' ] . includes ( targetTag )
75+ console . log ( '[LinkItemContainerNoBox] Checking target' , {
76+ targetTag,
77+ targetTagRaw : ( event . target as HTMLElement ) ?. tagName ,
78+ isButton : targetTag === 'button' ,
79+ isSvg : targetTag === 'svg' ,
80+ isPath : targetTag === 'path' ,
81+ willPreventDefault : isMenuTrigger ,
82+ } )
83+ if ( isMenuTrigger ) {
84+ console . log ( '[LinkItemContainerNoBox] Click on button/svg/path detected, preventing default AND stopping propagation' )
7685 event . preventDefault ( )
86+ event . stopPropagation ( )
7787 }
7888
7989 // Call Item's onClick first (handles selection logic)
@@ -102,9 +112,15 @@ const LinkItemContainerNoBox = React.forwardRef<HTMLAnchorElement, LinkItemConta
102112 hasOnClick : ! ! onClick ,
103113 hasUserOnClick : ! ! userOnClick ,
104114 restKeys : Object . keys ( rest ) ,
115+ hasTo : 'to' in rest ,
105116 } )
117+
118+ // Remove 'to' prop to prevent React Router from handling navigation
119+ // The onClick handlers will manage navigation and menu opening
120+ const { to : _ , ...restWithoutTo } = rest as typeof rest & { to ?: unknown }
121+
106122 return (
107- < Link as = { Component } ref = { forwardedRef } { ...rest } onClick = { clickHandler } >
123+ < Link as = { Component } ref = { forwardedRef } { ...restWithoutTo } onClick = { clickHandler } >
108124 { children }
109125 </ Link >
110126 )
0 commit comments