Skip to content

Build your personal knowledge base with Trilium Notes

style/right pane toggle handle: fix some issues

Adorian Doran152fd2331fdb
diff --git a/apps/client/src/widgets/sidebar/RightPaneToggleHandle.tsx b/apps/client/src/widgets/sidebar/RightPaneToggleHandle.tsx
index 83d39ef5eb..cd744d90a0 100644
--- a/apps/client/src/widgets/sidebar/RightPaneToggleHandle.tsx
+++ b/apps/client/src/widgets/sidebar/RightPaneToggleHandle.tsx
@@ -2,27 +2,25 @@ import "./RightPaneToggleHandle.css";
import { Tooltip } from "bootstrap";
import clsx from "clsx";
-import { useCallback, useMemo, useRef, useState } from "preact/hooks";
+import { useCallback, useMemo, useRef } from "preact/hooks";
import appContext from "../../components/app_context";
import { t } from "../../services/i18n";
-import options from "../../services/options";
-import { useStaticTooltip, useTriliumEvent } from "../react/hooks";
+import { useStaticTooltip } from "../react/hooks";
// Gap (px) between the handle and its tooltip, so the tooltip can't overlap the handle.
const TOOLTIP_MARGIN_PX = 8;
-export default function RightPaneToggleHandle() {
+interface RightPaneToggleHandleProps {
+ /** Owned and persisted by RightPanelContainer; this component only reflects it. */
+ rightPaneVisible: boolean;
+}
+
+export default function RightPaneToggleHandle({ rightPaneVisible }: RightPaneToggleHandleProps) {
const buttonRef = useRef<HTMLButtonElement>(null);
// Pointer's vertical position captured once on hover; null until the mouse enters
// (e.g. on keyboard focus) so the tooltip falls back to the handle's centre.
const pointerY = useRef<number | null>(null);
- const [ rightPaneVisible, setRightPaneVisible ] = useState(options.is("rightPaneVisible"));
-
- // Mirror the state so the arrow direction stays in sync; RightPanelContainer owns persistence.
- useTriliumEvent("toggleRightPane", useCallback(() => {
- setRightPaneVisible(current => !current);
- }, []));
const handleClick = useCallback(() => {
appContext.triggerCommand("toggleRightPane");
@@ -60,6 +58,7 @@ export default function RightPaneToggleHandle() {
rightPaneVisible ? "right-pane-toggle-handle-action-collapse" : "right-pane-toggle-handle-action-expand"
)}
onMouseEnter={(e) => { pointerY.current = e.clientY; }}
+ onMouseLeave={() => { pointerY.current = null; }}
onClick={handleClick}
/>
);
diff --git a/apps/client/src/widgets/sidebar/RightPanelContainer.css b/apps/client/src/widgets/sidebar/RightPanelContainer.css
index cfaa60a570..8c7ad008fc 100644
--- a/apps/client/src/widgets/sidebar/RightPanelContainer.css
+++ b/apps/client/src/widgets/sidebar/RightPanelContainer.css
@@ -5,7 +5,7 @@
body.experimental-feature-new-layout #vertical-main-container {
--right-pane-handle-width: 12px;
position: relative;
- /* +2px leaves a small gap between the panel (and #center-pane) and the handle. */
+ /* +4px leaves a small gap between the panel (and #center-pane) and the handle. */
padding-inline-end: calc(var(--right-pane-handle-width) + 4px);
}
diff --git a/apps/client/src/widgets/sidebar/RightPanelContainer.tsx b/apps/client/src/widgets/sidebar/RightPanelContainer.tsx
index db79a2b4cf..84d10c2470 100644
--- a/apps/client/src/widgets/sidebar/RightPanelContainer.tsx
+++ b/apps/client/src/widgets/sidebar/RightPanelContainer.tsx
@@ -49,7 +49,7 @@ export default function RightPanelContainer({ widgetsByParent }: { widgetsByPare
<>
{/* Absolutely positioned in a reserved gutter on the viewport's right edge, so it
stays put regardless of the panel's open/collapsed state (see RightPanelContainer.css). */}
- <RightPaneToggleHandle />
+ <RightPaneToggleHandle rightPaneVisible={rightPaneVisible} />
<div id="right-pane">
{rightPaneVisible && (
items.length > 0 ? (