Skip to content

Commit 9146fd1

Browse files
committed
fix: gamepad navigation from search to account dropdown on Library page
1 parent ed26a88 commit 9146fd1

3 files changed

Lines changed: 30 additions & 1 deletion

File tree

src/frontend/components/UI/AccountDropdown/index.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,14 @@ const WalletDropdown: React.FC = observer(() => {
4646
const showMetaMaskExtensionLinks =
4747
walletState.isConnected &&
4848
walletState.provider === PROVIDERS.METAMASK_EXTENSION
49+
const [opened, setOpened] = React.useState(false)
4950

5051
return (
5152
<Menu
5253
position="bottom-end"
5354
trigger="hover"
55+
opened={opened}
56+
onChange={setOpened}
5457
zIndex={100001}
5558
classNames={{
5659
dropdown: styles.menuDropdown,
@@ -64,6 +67,7 @@ const WalletDropdown: React.FC = observer(() => {
6467
onClick={() => {
6568
console.log('wallet clicked')
6669
}}
70+
onFocus={() => setOpened(true)}
6771
/>
6872
</div>
6973
</Menu.Target>

src/frontend/components/UI/TopNavBar/index.tsx

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,33 @@ const TopNavBar = observer(() => {
5858
}
5959
}
6060
}
61+
62+
// Right arrow navigation on /library page
63+
if (e.key === 'ArrowRight' && pathname === '/library') {
64+
const activeEl = document.activeElement as HTMLElement | null
65+
66+
// From MetaMask button -> Account dropdown
67+
if (activeEl?.closest('#topbarMetaMaskButton')) {
68+
const accountBtn = document.getElementById('accountWalletContainer')
69+
if (accountBtn) {
70+
accountBtn.focus()
71+
e.preventDefault()
72+
e.stopPropagation()
73+
}
74+
return
75+
}
76+
77+
// From Account dropdown -> stay there
78+
if (activeEl?.closest('#accountWalletContainer')) {
79+
e.preventDefault()
80+
e.stopPropagation()
81+
return
82+
}
83+
}
6184
}
6285
nav.addEventListener('keydown', onKeyDown)
6386
return () => nav.removeEventListener('keydown', onKeyDown)
64-
}, [])
87+
}, [pathname])
6588

6689
function getStoreTextStyle(viewURL: string) {
6790
const { currentUrl } = webviewNavigationStore

src/frontend/components/UI/Wallet/index.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import walletState from '../../../state/WalletState'
88

99
interface WalletProps {
1010
onClick: () => void
11+
onFocus?: () => void
1112
}
1213

1314
const WalletProviderIcons: Record<PROVIDERS, ReactNode> = {
@@ -23,6 +24,7 @@ const Wallet: React.FC<WalletProps> = observer((props) => {
2324
return (
2425
<button
2526
onClick={props.onClick}
27+
onFocus={props.onFocus}
2628
className={styles.walletButton}
2729
id="accountWalletContainer"
2830
>

0 commit comments

Comments
 (0)