diff --git a/app/components/Sidebar/App.tsx b/app/components/Sidebar/App.tsx
index c107114d1e..a5b6453103 100644
--- a/app/components/Sidebar/App.tsx
+++ b/app/components/Sidebar/App.tsx
@@ -57,7 +57,6 @@ function AppSidebar() {
return (
-
{dndArea && (
@@ -133,6 +132,7 @@ function AppSidebar() {
)}
+
);
}
diff --git a/app/components/Sidebar/Settings.tsx b/app/components/Sidebar/Settings.tsx
index fd15560e4b..bfd51ca30b 100644
--- a/app/components/Sidebar/Settings.tsx
+++ b/app/components/Sidebar/Settings.tsx
@@ -44,7 +44,6 @@ function SettingsSidebar() {
return (
-
}
@@ -96,6 +95,7 @@ function SettingsSidebar() {
)}
+
);
}
diff --git a/app/components/Sidebar/components/HistoryNavigation.tsx b/app/components/Sidebar/components/HistoryNavigation.tsx
index 58519b407a..894f06ad4b 100644
--- a/app/components/Sidebar/components/HistoryNavigation.tsx
+++ b/app/components/Sidebar/components/HistoryNavigation.tsx
@@ -3,54 +3,50 @@ import * as React from "react";
import { useTranslation } from "react-i18next";
import styled from "styled-components";
import { s } from "@shared/styles";
-import { isMac } from "@shared/utils/browser";
import Flex from "~/components/Flex";
import NudeButton from "~/components/NudeButton";
import Tooltip from "~/components/Tooltip";
-import useKeyDown from "~/hooks/useKeyDown";
import Desktop from "~/utils/Desktop";
function HistoryNavigation(props: React.ComponentProps) {
const { t } = useTranslation();
- const [back, setBack] = React.useState(false);
- const [forward, setForward] = React.useState(false);
+ const [canGoBack, setCanGoBack] = React.useState(false);
+ const [canGoForward, setCanGoForward] = React.useState(false);
+ const [supported, setSupported] = React.useState(false);
- useKeyDown(
- (event) =>
- isMac
- ? event.metaKey && event.key === "["
- : event.altKey && event.key === "ArrowLeft",
- () => {
- setBack(true);
- setTimeout(() => setBack(false), 100);
+ React.useEffect(() => {
+ if (!(Desktop.bridge && "onNavigationStateChanged" in Desktop.bridge)) {
+ return;
}
- );
+ setSupported(true);
+ return Desktop.bridge.onNavigationStateChanged((state) => {
+ setCanGoBack(state.canGoBack);
+ setCanGoForward(state.canGoForward);
+ });
+ }, []);
- useKeyDown(
- (event) =>
- isMac
- ? event.metaKey && event.key === "]"
- : event.altKey && event.key === "ArrowRight",
- () => {
- setForward(true);
- setTimeout(() => setForward(false), 100);
- }
- );
-
- if (!Desktop.isMacApp()) {
+ if (!Desktop.isMacApp() || !supported) {
return null;
}
return (
- Desktop.bridge?.goBack()}>
-
+ Desktop.bridge?.goBack()}
+ >
+
- Desktop.bridge?.goForward()}>
-
+ Desktop.bridge?.goForward()}
+ >
+
@@ -61,16 +57,20 @@ const Navigation = styled(Flex)`
position: absolute;
right: 12px;
top: 14px;
+
+ button {
+ cursor: default;
+ }
`;
-const Forward = styled(ArrowIcon)<{ $active: boolean }>`
+const Forward = styled(ArrowIcon)<{ $enabled: boolean }>`
color: ${s("textTertiary")};
- opacity: ${(props) => (props.$active ? 1 : 0.5)};
+ opacity: ${(props) => (props.$enabled ? 0.5 : 0.15)};
transition: color 100ms ease-in-out;
&:active,
&:hover {
- opacity: 1;
+ opacity: ${(props) => (props.$enabled ? 1 : 0.15)};
}
`;
diff --git a/app/typings/window.d.ts b/app/typings/window.d.ts
index 331760ccdd..3793bde19a 100644
--- a/app/typings/window.d.ts
+++ b/app/typings/window.d.ts
@@ -101,6 +101,14 @@ declare global {
*/
goForward: () => void;
+ /**
+ * Registers a callback to be called when the navigation state changes (e.g. after
+ * navigating to a new page). Receives whether back/forward navigation is possible.
+ */
+ onNavigationStateChanged: (
+ callback: (state: { canGoBack: boolean; canGoForward: boolean }) => void
+ ) => () => void;
+
/**
* Registers a callback to be called when the application wants to open the find in page dialog.
*/