diff --git a/src/entries/popup/components/TransactionFee/TransactionFee.tsx b/src/entries/popup/components/TransactionFee/TransactionFee.tsx index c5b172162a..5bfc248721 100644 --- a/src/entries/popup/components/TransactionFee/TransactionFee.tsx +++ b/src/entries/popup/components/TransactionFee/TransactionFee.tsx @@ -45,6 +45,7 @@ import { SwitchTransactionSpeedMenu } from './TransactionSpeedsMenu'; type FeeProps = { chainId: ChainId; + disableShortcuts?: boolean; accentColor?: string; plainTriggerBorder?: boolean; selectedSpeed: GasSpeed; @@ -71,6 +72,7 @@ function Fee({ analyticsEvents, baseFeeTrend, chainId, + disableShortcuts, currentBaseFee, gasFeeParamsBySpeed, isLoading, @@ -130,22 +132,24 @@ function Fee({ useKeyboardShortcut({ handler: (e: KeyboardEvent) => { - if (e.key === shortcuts.global.OPEN_CUSTOM_GAS_MENU.key) { - if (chainId === ChainId.mainnet) { - trackShortcut({ - key: shortcuts.global.OPEN_CUSTOM_GAS_MENU.display, - type: 'customGasMenu.open', - }); - // hackery preventing GweiInputMask from firing an onChange event when opening the menu with KB - setTimeout(() => openCustomGasSheet(), 0); - } - } else if (e.key === shortcuts.global.OPEN_GAS_MENU.key) { - if (chainId === ChainId.mainnet || chainId === ChainId.polygon) { - trackShortcut({ - key: shortcuts.global.OPEN_GAS_MENU.display, - type: 'gasMenu.open', - }); - switchTransactionSpeedMenuRef?.current?.open(); + if (!disableShortcuts) { + if (e.key === shortcuts.global.OPEN_CUSTOM_GAS_MENU.key) { + if (chainId === ChainId.mainnet) { + trackShortcut({ + key: shortcuts.global.OPEN_CUSTOM_GAS_MENU.display, + type: 'customGasMenu.open', + }); + // hackery preventing GweiInputMask from firing an onChange event when opening the menu with KB + setTimeout(() => openCustomGasSheet(), 0); + } + } else if (e.key === shortcuts.global.OPEN_GAS_MENU.key) { + if (chainId === ChainId.mainnet || chainId === ChainId.polygon) { + trackShortcut({ + key: shortcuts.global.OPEN_GAS_MENU.display, + type: 'gasMenu.open', + }); + switchTransactionSpeedMenuRef?.current?.open(); + } } } }, @@ -256,6 +260,7 @@ function Fee({ type TransactionFeeProps = { chainId: ChainId; + disableShortcuts?: boolean; address?: Address; defaultSpeed?: GasSpeed; transactionRequest: TransactionRequest; @@ -271,6 +276,7 @@ type TransactionFeeProps = { export function TransactionFee({ chainId, + disableShortcuts, address, defaultSpeed, transactionRequest, @@ -302,6 +308,7 @@ export function TransactionFee({ return ( { - if (e.altKey) { - if (e.key === shortcuts.send.FOCUS_TO_ADDRESS.key) { - trackShortcut({ - key: shortcuts.send.FOCUS_TO_ADDRESS.display, - type: 'send.focusToAddress', - }); - toAddressInputRef?.current?.focus(); - sendTokenInputRef?.current?.blur(); - } - if (e.key === shortcuts.send.FOCUS_ASSET.key) { - trackShortcut({ - key: shortcuts.send.FOCUS_ASSET.display, - type: 'send.focusAsset', - }); - toAddressInputRef?.current?.blur(); - sendTokenInputRef.current?.focus(); - } - } else { - if (!toAddressInputRef.current?.isFocused?.()) { - if (e.key === shortcuts.send.SET_MAX_AMOUNT.key) { + if (!explainerSheetParams.show && !contactSaveAction.show) { + if (e.altKey) { + if (e.key === shortcuts.send.FOCUS_TO_ADDRESS.key) { trackShortcut({ - key: shortcuts.send.SET_MAX_AMOUNT.display, - type: 'send.setMax', + key: shortcuts.send.FOCUS_TO_ADDRESS.display, + type: 'send.focusToAddress', }); - setMaxAssetAmount(); + toAddressInputRef?.current?.focus(); + sendTokenInputRef?.current?.blur(); } - if (e.key === shortcuts.send.SWITCH_CURRENCY_LABEL.key) { + if (e.key === shortcuts.send.FOCUS_ASSET.key) { trackShortcut({ - key: shortcuts.send.SWITCH_CURRENCY_LABEL.display, - type: 'send.switchCurrency', + key: shortcuts.send.FOCUS_ASSET.display, + type: 'send.focusAsset', }); - switchIndependentField(); + toAddressInputRef?.current?.blur(); + sendTokenInputRef.current?.focus(); + } + } else { + if (!toAddressInputRef.current?.isFocused?.()) { + if (e.key === shortcuts.send.SET_MAX_AMOUNT.key) { + trackShortcut({ + key: shortcuts.send.SET_MAX_AMOUNT.display, + type: 'send.setMax', + }); + setMaxAssetAmount(); + } + if (e.key === shortcuts.send.SWITCH_CURRENCY_LABEL.key) { + trackShortcut({ + key: shortcuts.send.SWITCH_CURRENCY_LABEL.display, + type: 'send.switchCurrency', + }); + switchIndependentField(); + } + } + if ( + e.key === shortcuts.send.OPEN_CONTACT_MENU.key && + !valueInputRef.current?.isFocused?.() + ) { + trackShortcut({ + key: shortcuts.send.OPEN_CONTACT_MENU.display, + type: 'send.openContactMenu', + }); + clickHeaderRight(); } - } - if ( - e.key === shortcuts.send.OPEN_CONTACT_MENU.key && - !valueInputRef.current?.isFocused?.() - ) { - trackShortcut({ - key: shortcuts.send.OPEN_CONTACT_MENU.display, - type: 'send.openContactMenu', - }); - clickHeaderRight(); } } }, @@ -753,6 +755,7 @@ export function Send() {