Skip to content

Commit bebab2f

Browse files
committed
Allow tooltip to wrap for long combo hotkeys
Replace whitespace-nowrap with max-w-[88px] and text-center so 3-key combos like Ctrl+Shift+K wrap gracefully within the 96px overlay window. Remove unused formatHotkeyCompact symbol approach.
1 parent 288e544 commit bebab2f

2 files changed

Lines changed: 3 additions & 41 deletions

File tree

src/App.jsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { X } from "lucide-react";
55
import { useToast } from "./components/ui/Toast";
66
import { LoadingDots } from "./components/ui/LoadingDots";
77
import { useHotkey } from "./hooks/useHotkey";
8-
import { formatHotkeyCompact } from "./utils/hotkeys";
8+
import { formatHotkeyLabel } from "./utils/hotkeys";
99
import { useWindowDrag } from "./hooks/useWindowDrag";
1010
import { useAudioRecording } from "./hooks/useAudioRecording";
1111
import { useSettingsStore } from "./stores/settingsStore";
@@ -57,7 +57,7 @@ const Tooltip = ({ children, content, emoji }) => {
5757
{children}
5858
</div>
5959
{isVisible && (
60-
<div className="absolute bottom-full left-1/2 transform -translate-x-1/2 mb-2 px-1.5 py-1 text-[10px] text-popover-foreground bg-popover border border-border rounded-md whitespace-nowrap z-10 shadow-lg transition-opacity duration-150">
60+
<div className="absolute bottom-full left-1/2 transform -translate-x-1/2 mb-2 px-1.5 py-1 text-[10px] text-popover-foreground bg-popover border border-border rounded-md z-10 shadow-lg transition-opacity duration-150 max-w-[88px] text-center leading-tight">
6161
{emoji && <span className="mr-1">{emoji}</span>}
6262
{content}
6363
<div className="absolute top-full left-1/2 transform -translate-x-1/2 w-0 h-0 border-l-2 border-r-2 border-t-2 border-transparent border-t-popover"></div>
@@ -277,7 +277,7 @@ export default function App() {
277277
case "hover":
278278
return {
279279
className: `${baseClasses} bg-black/50 cursor-pointer`,
280-
tooltip: formatHotkeyCompact(hotkey),
280+
tooltip: formatHotkeyLabel(hotkey),
281281
};
282282
case "recording":
283283
return {

src/utils/hotkeys.ts

Lines changed: 0 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -37,24 +37,6 @@ function formatModifierPart(part: string, platform: Platform): string {
3737
}
3838
}
3939

40-
const MODIFIER_SYMBOLS: Record<string, string> = {
41-
CommandOrControl: "⌘",
42-
Command: "⌘",
43-
Cmd: "⌘",
44-
Control: "⌃",
45-
Ctrl: "⌃",
46-
Alt: "⌥",
47-
Option: "⌥",
48-
Shift: "⇧",
49-
Super: "⌘",
50-
Meta: "⌘",
51-
Fn: "Fn",
52-
};
53-
54-
function formatModifierSymbol(part: string): string {
55-
return MODIFIER_SYMBOLS[part] ?? part;
56-
}
57-
5840
/**
5941
* Formats an Electron accelerator string into a user-friendly display label.
6042
*
@@ -73,26 +55,6 @@ export function formatHotkeyLabel(hotkey?: string | null): string {
7355
return formatHotkeyLabelForPlatform(resolvedHotkey, platform);
7456
}
7557

76-
/**
77-
* Compact hotkey label using symbols on macOS (e.g., "⌘⇧K") and short text elsewhere.
78-
* Designed for tight UI spaces like the 96px overlay tooltip.
79-
*/
80-
export function formatHotkeyCompact(hotkey?: string | null): string {
81-
const platform = getPlatform();
82-
const resolvedHotkey = hotkey && hotkey.trim() !== "" ? hotkey : getDefaultHotkey();
83-
84-
if (!resolvedHotkey || resolvedHotkey.trim() === "") return "";
85-
if (isGlobeLikeHotkey(resolvedHotkey)) return "Globe/Fn";
86-
87-
if (platform === "darwin" && resolvedHotkey.includes("+")) {
88-
const parts = resolvedHotkey.split("+");
89-
const symbols = parts.map((p) => formatModifierSymbol(p));
90-
return symbols.join("");
91-
}
92-
93-
return formatHotkeyLabelForPlatform(resolvedHotkey, platform);
94-
}
95-
9658
export function formatHotkeyLabelForPlatform(hotkey: string, platform: Platform): string {
9759
if (!hotkey || hotkey.trim() === "") {
9860
return "";

0 commit comments

Comments
 (0)