diff --git a/src/renderer/src/components/tab-bar/EditorFileTabCloseButton.tsx b/src/renderer/src/components/tab-bar/EditorFileTabCloseButton.tsx index fb135b92c9e..98ef2712dbf 100644 --- a/src/renderer/src/components/tab-bar/EditorFileTabCloseButton.tsx +++ b/src/renderer/src/components/tab-bar/EditorFileTabCloseButton.tsx @@ -1,7 +1,6 @@ import { X } from 'lucide-react' -import { ShortcutKeyCombo } from '@/components/ShortcutKeyCombo' import { Tooltip, TooltipContent, TooltipTrigger } from '@/components/ui/tooltip' -import { useShortcutKeyDetails } from '@/hooks/useShortcutLabel' +import { useOptionalShortcutLabel } from '@/hooks/useShortcutLabel' import { translate } from '@/i18n/i18n' export function EditorFileTabCloseButton({ @@ -13,7 +12,11 @@ export function EditorFileTabCloseButton({ showsSelectionChrome: boolean onClose: () => void }): React.JSX.Element { - const closeShortcut = useShortcutKeyDetails('tab.close') + const closeShortcut = useOptionalShortcutLabel('tab.close') + const closeLabel = translate( + 'auto.components.tab.bar.EditorFileTabCloseButton.a768f428f1', + 'Close tab' + ) return ( @@ -43,13 +46,8 @@ export function EditorFileTabCloseButton({ - - - {translate('auto.components.tab.bar.EditorFileTabCloseButton.a768f428f1', 'Close tab')} - - {closeShortcut.keys.length > 0 && ( - - )} + + {closeShortcut ? `${closeLabel} (${closeShortcut})` : closeLabel} ) diff --git a/src/renderer/src/components/tab-bar/SortableTab.tsx b/src/renderer/src/components/tab-bar/SortableTab.tsx index 34f11a451fb..075bfcbff89 100644 --- a/src/renderer/src/components/tab-bar/SortableTab.tsx +++ b/src/renderer/src/components/tab-bar/SortableTab.tsx @@ -6,7 +6,6 @@ import { useTabAgent } from '@/lib/use-tab-agent' import { isImeCompositionKeyDown } from '@/lib/ime-composition-keyboard-event' import { Input } from '@/components/ui/input' import { Tooltip, TooltipContent, TooltipTrigger } from '@/components/ui/tooltip' -import { ShortcutKeyCombo } from '@/components/ShortcutKeyCombo' import type { TerminalTab } from '../../../../shared/types' import type { TabDragItemData } from '../tab-group/useTabDragSplit' import { useAppStore } from '../../store' @@ -21,7 +20,7 @@ import { preventMiddleButtonDefault } from './middle-button-default-guard' import { SortableTabContextMenu } from './SortableTabContextMenu' import { translate } from '@/i18n/i18n' import { TAB_CONTAINER_WIDTH_CLASSES, TAB_LABEL_WIDTH_CLASSES } from './tab-width-rules' -import { useShortcutKeyDetails } from '@/hooks/useShortcutLabel' +import { useOptionalShortcutLabel } from '@/hooks/useShortcutLabel' import { useTabStripPointerActivation } from './tab-strip-pointer-activation' import { TerminalTabLeadingIcon } from './TerminalTabLeadingIcon' import { @@ -205,7 +204,8 @@ export default function SortableTab({ onActivate: handleActivate, disabled: isEditing }) - const closeShortcut = useShortcutKeyDetails('tab.close') + const closeShortcut = useOptionalShortcutLabel('tab.close') + const closeLabel = translate('auto.components.tab.bar.SortableTab.95db5f2f7d', 'Close tab') const tabTitle = tab.customTitle ?? tab.title const tabRoot = (
- - {translate('auto.components.tab.bar.SortableTab.95db5f2f7d', 'Close tab')} - {closeShortcut.keys.length > 0 && ( - - )} + + {closeShortcut ? `${closeLabel} (${closeShortcut})` : closeLabel} )}