11// Third party
2- import React , { useMemo , useState } from 'react'
2+ import React , { useState } from 'react'
33import { Navbar , NavLink , NavDropdown } from 'react-bootstrap'
44import { Link } from 'react-router-dom'
55
@@ -21,24 +21,30 @@ const Navigation = (): React.ReactElement => {
2121
2222 // State for handling dropdown visibility
2323 const [ showDropdown , setShowDropdown ] = useState ( false )
24- const isDesktop = useMemo ( ( ) => {
25- if ( typeof window === 'undefined' ) return false
26- return window . matchMedia ( '(hover: hover) and (pointer: fine)' ) . matches
27- } , [ ] )
24+ // const isDesktop = useMemo(() => {
25+ // if (typeof window === 'undefined') return false
26+ // return window.matchMedia('(hover: hover) and (pointer: fine)').matches
27+ // }, [])
28+
29+ const isDesktop = ( ) : boolean => {
30+ if ( width < Constants . MOBILE_SIZE )
31+ return false
32+ return true
33+ }
2834 // Timeout variable to prevent flickering
2935 let hideDropdownTimeout : NodeJS . Timeout
3036
3137 // Open dropdown when hovering over "Projects"
3238 const handleMouseEnter = ( ) : void => {
33- if ( isDesktop ) {
39+ if ( isDesktop ( ) ) {
3440 clearTimeout ( hideDropdownTimeout ) // Cancel hide if mouse enters again
3541 setShowDropdown ( true )
3642 }
3743 }
3844
3945 // Close dropdown when mouse leaves (with small delay)
4046 const handleMouseLeave = ( ) : void => {
41- if ( isDesktop ) {
47+ if ( isDesktop ( ) ) {
4248 hideDropdownTimeout = setTimeout ( ( ) => {
4349 setShowDropdown ( false )
4450 } , 400 ) // Small delay before closing
@@ -82,7 +88,7 @@ const Navigation = (): React.ReactElement => {
8288 show = { showDropdown }
8389 className = 'nav-link'
8490 onToggle = { ( nextShow /* boolean */ ) => {
85- if ( ! isDesktop ) setShowDropdown ( nextShow )
91+ if ( ! isDesktop ( ) ) setShowDropdown ( nextShow )
8692 } }
8793 // Close on any item selection
8894 onSelect = { ( ) => setShowDropdown ( false ) } >
0 commit comments