@@ -3,6 +3,7 @@ import type {Theme} from '@emotion/react';
3
3
import { css , useTheme } from '@emotion/react' ;
4
4
import styled from '@emotion/styled' ;
5
5
import { useHover } from '@react-aria/interactions' ;
6
+ import { mergeProps } from '@react-aria/utils' ;
6
7
7
8
import type { ButtonProps } from 'sentry/components/core/button' ;
8
9
import { Button } from 'sentry/components/core/button' ;
@@ -170,7 +171,7 @@ function useActivateNavGroupOnHover(group: PrimaryNavGroup) {
170
171
171
172
// Slightly delay changing the active nav group to prevent accidentally triggering a new menu
172
173
const timeoutRef = useRef < NodeJS . Timeout | null > ( null ) ;
173
- return useHover ( {
174
+ const { hoverProps } = useHover ( {
174
175
onHoverStart : ( ) => {
175
176
if ( timeoutRef . current ) {
176
177
clearTimeout ( timeoutRef . current ) ;
@@ -191,6 +192,15 @@ function useActivateNavGroupOnHover(group: PrimaryNavGroup) {
191
192
}
192
193
} ,
193
194
} ) ;
195
+
196
+ return mergeProps ( hoverProps , {
197
+ onClick : ( ) => {
198
+ setActivePrimaryNavGroup ( group ) ;
199
+ if ( timeoutRef . current ) {
200
+ clearTimeout ( timeoutRef . current ) ;
201
+ }
202
+ } ,
203
+ } ) ;
194
204
}
195
205
196
206
function SidebarNavLink ( {
@@ -206,22 +216,24 @@ function SidebarNavLink({
206
216
const location = useLocation ( ) ;
207
217
const isActive = isLinkActive ( normalizeUrl ( activeTo , location ) , location . pathname ) ;
208
218
const label = PRIMARY_NAV_GROUP_CONFIG [ group ] . label ;
209
- const { hoverProps} = useActivateNavGroupOnHover ( group ) ;
219
+ const hoverProps = useActivateNavGroupOnHover ( group ) ;
220
+ const linkProps = mergeProps ( hoverProps , {
221
+ onClick : ( ) => {
222
+ recordPrimaryItemClick ( analyticsKey , organization ) ;
223
+ } ,
224
+ } ) ;
210
225
211
226
return (
212
227
< NavLink
213
228
to = { to }
214
229
state = { { source : SIDEBAR_NAVIGATION_SOURCE } }
215
- onClick = { ( ) => {
216
- recordPrimaryItemClick ( analyticsKey , organization ) ;
217
- } }
218
230
aria-selected = { activePrimaryNavGroup === group ? true : isActive }
219
231
aria-current = { isActive ? 'page' : undefined }
220
232
isMobile = { layout === NavLayout . MOBILE }
221
233
{ ...{
222
234
[ NAV_PRIMARY_LINK_DATA_ATTRIBUTE ] : true ,
223
235
} }
224
- { ...hoverProps }
236
+ { ...linkProps }
225
237
>
226
238
{ layout === NavLayout . MOBILE ? (
227
239
< Fragment >
0 commit comments