this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Attempt to fix lost focus when closing nav menu

+9 -14
+9 -14
src/components/nav-menu.jsx
··· 1 - import { 2 - ControlledMenu, 3 - MenuDivider, 4 - MenuItem, 5 - useClick, 6 - useMenuState, 7 - } from '@szhsin/react-menu'; 8 - import { useRef } from 'preact/hooks'; 1 + import { ControlledMenu, MenuDivider, MenuItem } from '@szhsin/react-menu'; 2 + import { useRef, useState } from 'preact/hooks'; 9 3 import { useLongPress } from 'use-long-press'; 10 4 import { useSnapshot } from 'valtio'; 11 5 ··· 47 41 ); 48 42 49 43 const buttonRef = useRef(); 50 - const [menuState, toggleMenu] = useMenuState(); 51 - const anchorProps = useClick(menuState.state, toggleMenu); 44 + const [menuState, setMenuState] = useState(undefined); 52 45 53 46 return ( 54 47 <> ··· 59 52 moreThanOneAccount ? 'with-avatar' : '' 60 53 } ${open ? 'active' : ''}`} 61 54 style={{ position: 'relative' }} 62 - {...anchorProps} 55 + onClick={() => { 56 + setMenuState((state) => (!state ? 'open' : undefined)); 57 + }} 63 58 onContextMenu={(e) => { 64 59 e.preventDefault(); 65 60 states.showAccounts = true; ··· 78 73 <Icon icon="menu" size={moreThanOneAccount ? 's' : 'l'} /> 79 74 </button> 80 75 <ControlledMenu 81 - {...menuState} 76 + state={menuState} 82 77 anchorRef={buttonRef} 83 78 onClose={() => { 84 - toggleMenu(false); 79 + setMenuState(undefined); 85 80 }} 86 81 containerProps={{ 87 82 style: { 88 83 zIndex: 10, 89 84 }, 90 85 onClick: () => { 91 - toggleMenu(false); 86 + setMenuState(undefined); 92 87 }, 93 88 }} 94 89 portal={{