diff options
| author | Oskar Nyberg <oskar@mullvad.net> | 2022-03-14 13:59:05 +0100 |
|---|---|---|
| committer | Oskar Nyberg <oskar@mullvad.net> | 2022-03-14 13:59:05 +0100 |
| commit | 4ab205bd9add69264ccdfaaf8cf068515ceddb77 (patch) | |
| tree | 302357507a7e51ece04f563c5f7018d64adaccac /gui/src/renderer/components/KeyboardNavigation.tsx | |
| parent | 6459ae7beefcc5f13eb54254dfe402dd807c62fe (diff) | |
| parent | 55aa3418f8b7ec6f473fd22819f7e54cb432d097 (diff) | |
| download | mullvadvpn-4ab205bd9add69264ccdfaaf8cf068515ceddb77.tar.xz mullvadvpn-4ab205bd9add69264ccdfaaf8cf068515ceddb77.zip | |
Merge branch 'device-api-electron'
Diffstat (limited to 'gui/src/renderer/components/KeyboardNavigation.tsx')
| -rw-r--r-- | gui/src/renderer/components/KeyboardNavigation.tsx | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/gui/src/renderer/components/KeyboardNavigation.tsx b/gui/src/renderer/components/KeyboardNavigation.tsx index 4cfba89452..6b3851a49f 100644 --- a/gui/src/renderer/components/KeyboardNavigation.tsx +++ b/gui/src/renderer/components/KeyboardNavigation.tsx @@ -1,5 +1,7 @@ import React, { useCallback, useContext, useEffect, useMemo, useState } from 'react'; +import { useLocation } from 'react-router'; import { useHistory } from '../lib/history'; +import { disableDismissForRoutes, RoutePath } from '../lib/routes'; interface IKeyboardNavigationProps { children: React.ReactElement; @@ -9,18 +11,22 @@ interface IKeyboardNavigationProps { export default function KeyboardNavigation(props: IKeyboardNavigationProps) { const history = useHistory(); const [backAction, setBackAction] = useState<IBackActionConfiguration>(); + const location = useLocation(); const handleKeyDown = useCallback( (event: KeyboardEvent) => { if (event.key === 'Escape') { - if (event.shiftKey) { - history.dismiss(true); - } else { - backAction?.action(); + const path = location.pathname as RoutePath; + if (!disableDismissForRoutes.includes(path)) { + if (event.shiftKey) { + history.dismiss(true); + } else { + backAction?.action(); + } } } }, - [history.dismiss, backAction], + [history.dismiss, backAction, location.pathname], ); useEffect(() => { |
