diff --git a/src/entries/popup/components/BackupReminder/BackupReminder.tsx b/src/entries/popup/components/BackupReminder/BackupReminder.tsx index c4ed644c70..6f61c2b69a 100644 --- a/src/entries/popup/components/BackupReminder/BackupReminder.tsx +++ b/src/entries/popup/components/BackupReminder/BackupReminder.tsx @@ -1,6 +1,7 @@ import React from 'react'; import { i18n } from '~/core/languages'; +import { shortcuts } from '~/core/references/shortcuts'; import { Box, Button, @@ -13,6 +14,7 @@ import { } from '~/design-system'; import { BottomSheet } from '~/design-system/components/BottomSheet/BottomSheet'; +import { useKeyboardShortcut } from '../../hooks/useKeyboardShortcut'; import { useRainbowNavigate } from '../../hooks/useRainbowNavigate'; import { useWalletBackups } from '../../hooks/useWalletBackups'; import { ROUTES } from '../../urls'; @@ -23,13 +25,23 @@ export const BackupReminder = () => { const { showWalletBackupReminder, closeBackupReminder } = useWalletBackups(); const navigate = useRainbowNavigate(); + useKeyboardShortcut({ + condition: () => showWalletBackupReminder, + handler: (e: KeyboardEvent) => { + if (e.key === shortcuts.global.CLOSE.key) { + e.preventDefault(); + closeBackupReminder(); + } + }, + }); + return ( - + { }, }); }} + tabIndex={0} > {i18n.t('wallet_backup_reminder.button_label_action')} @@ -102,6 +115,7 @@ export const BackupReminder = () => { height="44px" variant="tinted" onClick={closeBackupReminder} + tabIndex={0} > { + useKeyboardShortcut({ + condition: () => !!show, + handler: (e: KeyboardEvent) => { + if (e.key === shortcuts.global.CLOSE.key) { + e.preventDefault(); + onClickOutside?.(); + } + }, + }); + const goToLink = useCallback((link?: string) => { link && goToNewTab({ diff --git a/src/entries/popup/hooks/useHomeShortcuts.ts b/src/entries/popup/hooks/useHomeShortcuts.ts index 23128ec5b5..86c26addd1 100644 --- a/src/entries/popup/hooks/useHomeShortcuts.ts +++ b/src/entries/popup/hooks/useHomeShortcuts.ts @@ -22,6 +22,7 @@ import { ROUTES } from '../urls'; import { appConnectionMenuIsActive, appConnectionSwitchWalletsPromptIsActive, + getExplainerSheet, getInputIsFocused, } from '../utils/activeElement'; import { @@ -104,7 +105,9 @@ export function useHomeShortcuts() { const activeAppWalletSwitcher = appConnectionSwitchWalletsPromptIsActive(); const inputIsFocused = getInputIsFocused(); + const isExplainerSheet = getExplainerSheet(); if (inputIsFocused) return; + if (isExplainerSheet) return; switch (e.key) { case shortcuts.home.BUY.key: trackShortcut({ diff --git a/src/entries/popup/pages/home/TokenDetails/About.tsx b/src/entries/popup/pages/home/TokenDetails/About.tsx index 3ebd6fd417..38ba57a675 100644 --- a/src/entries/popup/pages/home/TokenDetails/About.tsx +++ b/src/entries/popup/pages/home/TokenDetails/About.tsx @@ -1,5 +1,5 @@ import clsx from 'clsx'; -import { ReactNode, useReducer } from 'react'; +import { ReactNode, useState } from 'react'; import { i18n } from '~/core/languages'; import { ParsedUserAsset } from '~/core/types/assets'; @@ -95,10 +95,7 @@ export const InfoRow = ({ ); function MarketCapInfoRow({ marketCap }: { marketCap: ReactNode }) { - const [isMarketCapExplainerOpen, toggleMarketCapExplainer] = useReducer( - (s) => !s, - false, - ); + const [isOpen, setIsOpen] = useState(false); return ( <> setIsOpen(true)} > {i18n.t(`token_details.about.market_cap`)} setIsOpen(false)} actionButton={{ label: i18n.t('token_details.about.market_cap_explainer.action'), variant: 'tinted', labelColor: 'blue', - action: toggleMarketCapExplainer, + action: () => setIsOpen(false), }} header={{ emoji: '📈' }} /> @@ -141,11 +138,7 @@ function MarketCapInfoRow({ marketCap }: { marketCap: ReactNode }) { } function FullyDilutedInfoRow({ fullyDiluted }: { fullyDiluted: ReactNode }) { - const [isFullyDilutedExplainerOpen, toggleFullyDilutedExplainer] = useReducer( - (s) => !s, - false, - ); - + const [isOpen, setIsOpen] = useState(false); return ( <> setIsOpen(true)} > {i18n.t(`token_details.about.fully_diluted`)} setIsOpen(false)} actionButton={{ label: i18n.t('token_details.about.fully_diluted_explainer.action'), variant: 'tinted', labelColor: 'blue', - action: toggleFullyDilutedExplainer, + action: () => setIsOpen(false), }} header={{ emoji: '📊' }} />