diff options
| author | Oskar Nyberg <oskar@mullvad.net> | 2024-02-14 15:11:30 +0100 |
|---|---|---|
| committer | Oskar Nyberg <oskar@mullvad.net> | 2024-02-15 16:04:29 +0100 |
| commit | 4aa7c62fd311efa57c9f086c32f8ebfd6c57ace4 (patch) | |
| tree | 5e100bc5faa75e2fcc8e7419069fa94a627f184b /gui/src/renderer/components | |
| parent | 60516d457dd0303b7794334dce458c171d4b5494 (diff) | |
| download | mullvadvpn-4aa7c62fd311efa57c9f086c32f8ebfd6c57ace4.tar.xz mullvadvpn-4aa7c62fd311efa57c9f086c32f8ebfd6c57ace4.zip | |
Improve logic for figuring out back button icon
Diffstat (limited to 'gui/src/renderer/components')
| -rw-r--r-- | gui/src/renderer/components/NavigationBar.tsx | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/gui/src/renderer/components/NavigationBar.tsx b/gui/src/renderer/components/NavigationBar.tsx index d07b918d56..ee316de783 100644 --- a/gui/src/renderer/components/NavigationBar.tsx +++ b/gui/src/renderer/components/NavigationBar.tsx @@ -1,9 +1,10 @@ import React, { useCallback, useContext, useEffect, useLayoutEffect, useMemo, useRef } from 'react'; +import styled from 'styled-components'; import { colors } from '../../config.json'; import { messages } from '../../shared/gettext'; import { useAppContext } from '../context'; -import { useHistory } from '../lib/history'; +import { transitions, useHistory } from '../lib/history'; import { useCombinedRefs } from '../lib/utilityHooks'; import CustomScrollbars, { CustomScrollbarsRef, IScrollEvent } from './CustomScrollbars'; import InfoButton from './InfoButton'; @@ -186,7 +187,9 @@ export const TitleBarItem = React.memo(function TitleBarItemT(props: ITitleBarIt export function BackBarItem() { const history = useHistory(); - const backIcon = useMemo(() => history.length > 2, []); + // Compare the transition name with dismiss to infer wheter or not the view will slide + // horizontally or vertically and then use matching button. + const backIcon = useMemo(() => history.getPopTransition().name !== transitions.dismiss.name, []); const { parentBackAction } = useContext(BackActionContext); const iconSource = backIcon ? 'icon-back' : 'icon-close-down'; const ariaLabel = backIcon ? messages.gettext('Back') : messages.gettext('Close'); |
