Skip to content

Commit 208ef3a

Browse files
committed
Redo keyboardshortcut
1 parent 58f4944 commit 208ef3a

File tree

3 files changed

+14
-16
lines changed

3 files changed

+14
-16
lines changed

packages/gitbook/src/components/AIChat/AIChatInput.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import { useHotkeys } from 'react-hotkeys-hook';
55
import { useAIChatState } from '../AI/useAIChat';
66
import { HoverCard, HoverCardRoot, HoverCardTrigger } from '../primitives';
77
import { Input } from '../primitives/Input';
8-
import { KeyboardShortcut } from '../primitives/KeyboardShortcut';
98

109
export function AIChatInput(props: {
1110
value: string;
@@ -65,11 +64,12 @@ export function AIChatInput(props: {
6564
className="animate-blur-in-slow bg-tint-base/9 backdrop-blur-lg contrast-more:bg-tint-base"
6665
rows={1}
6766
keyboardShortcut={
68-
!value && !disabled && !loading ? (
69-
<div className="group-focus-within/input:hidden">
70-
<KeyboardShortcut keys={['mod', 'i']} className="bg-tint-base" />
71-
</div>
72-
) : undefined
67+
!value && !disabled && !loading
68+
? {
69+
keys: ['mod', 'i'],
70+
className: 'bg-tint-base group-focus-within/input:hidden',
71+
}
72+
: undefined
7373
}
7474
disabled={disabled || loading}
7575
aria-busy={loading}

packages/gitbook/src/components/Search/SearchInput.tsx

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import React, { useEffect, useRef } from 'react';
33

44
import { tString, useLanguage } from '@/intl/client';
55
import { Input } from '../primitives';
6-
import { KeyboardShortcut } from '../primitives/KeyboardShortcut';
76

87
interface SearchInputProps {
98
onChange: (value: string) => void;
@@ -73,12 +72,11 @@ export const SearchInput = React.forwardRef<HTMLDivElement, SearchInputProps>(
7372
aria-haspopup="listbox"
7473
aria-expanded={value && isOpen ? 'true' : 'false'}
7574
clearButton
76-
keyboardShortcut={
77-
<KeyboardShortcut
78-
className="theme-bold:border-header-link/4 theme-bold:bg-header-background theme-bold:text-header-link"
79-
keys={isOpen ? ['esc'] : ['mod', 'k']}
80-
/>
81-
}
75+
keyboardShortcut={{
76+
className:
77+
'theme-bold:border-header-link/4 theme-bold:bg-header-background theme-bold:text-header-link',
78+
keys: isOpen ? ['esc'] : ['mod', 'k'],
79+
}}
8280
{...rest}
8381
type="text"
8482
/>

packages/gitbook/src/components/primitives/Input.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { tcls } from '@/lib/tailwind';
55
import { Icon, type IconName } from '@gitbook/icons';
66
import React, { type ReactNode } from 'react';
77
import { Button, type ButtonProps } from './Button';
8-
import { KeyboardShortcut } from './KeyboardShortcut';
8+
import { KeyboardShortcut, type KeyboardShortcutProps } from './KeyboardShortcut';
99

1010
export type InputProps = {
1111
label: string;
@@ -28,7 +28,7 @@ export type InputProps = {
2828
/**
2929
* A keyboard shortcut, shown to the right of the input.
3030
*/
31-
keyboardShortcut?: boolean | ReactNode;
31+
keyboardShortcut?: boolean | KeyboardShortcutProps;
3232

3333
onSubmit?: (value: string | number | readonly string[] | undefined) => void;
3434
resize?: boolean;
@@ -220,7 +220,7 @@ export const Input = React.forwardRef<HTMLInputElement | HTMLTextAreaElement, In
220220
<div className={multiline ? 'absolute top-2.5 right-2.5' : ''}>
221221
{keyboardShortcut !== false ? (
222222
typeof keyboardShortcut === 'object' ? (
223-
keyboardShortcut
223+
<KeyboardShortcut {...keyboardShortcut} />
224224
) : onSubmit && !submitted && hasValue ? (
225225
<KeyboardShortcut
226226
keys={['enter']}

0 commit comments

Comments
 (0)