mirror of
https://github.com/zadam/trilium.git
synced 2026-02-22 13:44:25 +01:00
fix(mobile/tree): "toggle sidebar" tooltip shown after opening sidebar
This commit is contained in:
parent
0110b3c4a2
commit
4ebc4ece34
@ -1,5 +1,5 @@
|
||||
import ActionButton from "../react/ActionButton";
|
||||
import { t } from "../../services/i18n";
|
||||
import ActionButton from "../react/ActionButton";
|
||||
import { useNoteContext } from "../react/hooks";
|
||||
|
||||
export default function ToggleSidebarButton() {
|
||||
@ -10,10 +10,15 @@ export default function ToggleSidebarButton() {
|
||||
{ noteContext?.isMainContext() && <ActionButton
|
||||
icon="bx bx-sidebar"
|
||||
text={t("note_tree.toggle-sidebar")}
|
||||
onClick={() => parentComponent?.triggerCommand("setActiveScreen", {
|
||||
screen: "tree"
|
||||
})}
|
||||
onClick={(e) => {
|
||||
// Remove focus to prevent tooltip showing on top of the sidebar.
|
||||
(e.currentTarget as HTMLButtonElement).blur();
|
||||
|
||||
parentComponent?.triggerCommand("setActiveScreen", {
|
||||
screen: "tree"
|
||||
});
|
||||
}}
|
||||
/>}
|
||||
</div>
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
@ -3,6 +3,7 @@ import { useEffect, useRef, useState } from "preact/hooks";
|
||||
|
||||
import { CommandNames } from "../../components/app_context";
|
||||
import keyboard_actions from "../../services/keyboard_actions";
|
||||
import { isMobile } from "../../services/utils";
|
||||
import { useStaticTooltip } from "./hooks";
|
||||
|
||||
export interface ActionButtonProps extends Pick<HTMLAttributes<HTMLButtonElement>, "onClick" | "onAuxClick" | "onContextMenu" | "style"> {
|
||||
@ -17,6 +18,8 @@ export interface ActionButtonProps extends Pick<HTMLAttributes<HTMLButtonElement
|
||||
disabled?: boolean;
|
||||
}
|
||||
|
||||
const cachedIsMobile = isMobile();
|
||||
|
||||
export default function ActionButton({ text, icon, className, triggerCommand, titlePosition, noIconActionClass, frame, active, disabled, ...restProps }: ActionButtonProps) {
|
||||
const buttonRef = useRef<HTMLButtonElement>(null);
|
||||
const [ keyboardShortcut, setKeyboardShortcut ] = useState<string[]>();
|
||||
@ -25,6 +28,7 @@ export default function ActionButton({ text, icon, className, triggerCommand, ti
|
||||
title: keyboardShortcut?.length ? `${text} (${keyboardShortcut?.join(",")})` : text,
|
||||
placement: titlePosition ?? "bottom",
|
||||
fallbackPlacements: [ titlePosition ?? "bottom" ],
|
||||
trigger: cachedIsMobile ? "focus" : "hover focus",
|
||||
animation: false
|
||||
});
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user