mirror of
				https://github.com/lingble/twenty.git
				synced 2025-10-31 20:57:55 +00:00 
			
		
		
		
	Fix remove redundant onClick event in favor of Link component (#8540)
Fixes: #8531 1. Summary There is `onClick` event handler defined for `NavigationDrawerItem` component, and inside the handler, if `to` is not empty, we trigger another navigation when it's already handled by `Link` component from `react-router-dom` 2. Solution Removed extra navigation logic from `NavigationDrawerItem`'s `onClick` handler 3. Screen Recording https://github.com/user-attachments/assets/cfefdd51-1663-4d96-acd2-57783ae9877f
This commit is contained in:
		| @@ -8,8 +8,7 @@ import { useIsMobile } from '@/ui/utilities/responsive/hooks/useIsMobile'; | |||||||
| import isPropValid from '@emotion/is-prop-valid'; | import isPropValid from '@emotion/is-prop-valid'; | ||||||
| import { useTheme } from '@emotion/react'; | import { useTheme } from '@emotion/react'; | ||||||
| import styled from '@emotion/styled'; | import styled from '@emotion/styled'; | ||||||
| import { isNonEmptyString } from '@sniptt/guards'; | import { Link } from 'react-router-dom'; | ||||||
| import { Link, useNavigate } from 'react-router-dom'; |  | ||||||
| import { useRecoilState } from 'recoil'; | import { useRecoilState } from 'recoil'; | ||||||
| import { | import { | ||||||
|   IconComponent, |   IconComponent, | ||||||
| @@ -168,7 +167,6 @@ export const NavigationDrawerItem = ({ | |||||||
|   const theme = useTheme(); |   const theme = useTheme(); | ||||||
|   const isMobile = useIsMobile(); |   const isMobile = useIsMobile(); | ||||||
|   const isSettingsPage = useIsSettingsPage(); |   const isSettingsPage = useIsSettingsPage(); | ||||||
|   const navigate = useNavigate(); |  | ||||||
|   const [isNavigationDrawerExpanded, setIsNavigationDrawerExpanded] = |   const [isNavigationDrawerExpanded, setIsNavigationDrawerExpanded] = | ||||||
|     useRecoilState(isNavigationDrawerExpandedState); |     useRecoilState(isNavigationDrawerExpandedState); | ||||||
|   const showBreadcrumb = indentationLevel === 2; |   const showBreadcrumb = indentationLevel === 2; | ||||||
| @@ -182,10 +180,6 @@ export const NavigationDrawerItem = ({ | |||||||
|       onClick(); |       onClick(); | ||||||
|       return; |       return; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     if (isNonEmptyString(to)) { |  | ||||||
|       navigate(to); |  | ||||||
|     } |  | ||||||
|   }; |   }; | ||||||
|  |  | ||||||
|   return ( |   return ( | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Khuddite
					Khuddite