Skip to content

Commit 1e53f46

Browse files
authored
Fix button content truncate (#3693)
1 parent 1a6216d commit 1e53f46

File tree

5 files changed

+12
-5
lines changed

5 files changed

+12
-5
lines changed

.changeset/spicy-trainers-dance.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"gitbook": patch
3+
---
4+
5+
Fix button content truncate

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
'use client';
22
import { useLanguage } from '@/intl/client';
33
import { t } from '@/intl/translate';
4-
import { tcls } from '@/lib/tailwind';
54
import type { Assistant } from '../AI';
65
import { Button } from '../primitives';
76
import { KeyboardShortcut } from '../primitives/KeyboardShortcut';
@@ -24,7 +23,7 @@ export function AIChatButton(props: {
2423
iconOnly={!showLabel}
2524
size="medium"
2625
variant="header"
27-
className={tcls('h-9 px-2.5')}
26+
className="h-9 px-2.5 max-md:[&_.button-content]:hidden"
2827
label={
2928
<div className="flex items-center gap-2">
3029
{t(language, 'ai_chat_ask', assistant.label)}
@@ -38,7 +37,7 @@ export function AIChatButton(props: {
3837
}
3938
onClick={() => assistant.open()}
4039
>
41-
{showLabel ? <span className="max-md:hidden">{t(language, 'ask')}</span> : null}
40+
{showLabel ? t(language, 'ask') : null}
4241
</Button>
4342
);
4443
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ export const SearchInput = React.forwardRef<HTMLDivElement, SearchInputProps>(
7272
'has-[input:focus]:-translate-y-px h-9 grow cursor-pointer px-2.5 has-[input:focus]:bg-tint-base has-[input:focus]:depth-subtle:shadow-lg has-[input:focus]:depth-subtle:shadow-primary-subtle has-[input:focus-visible]:ring-2 has-[input:focus-visible]:ring-primary-hover md:cursor-text',
7373
'theme-bold:border-header-link/3 has-[input:focus-visible]:theme-bold:border-header-link/5 has-[input:focus-visible]:theme-bold:bg-header-link/3 has-[input:focus-visible]:theme-bold:ring-header-link/5',
7474
'theme-bold:before:absolute theme-bold:before:inset-0 theme-bold:before:bg-header-background/7 theme-bold:before:backdrop-blur-xl ', // Special overlay to make the transparent colors of theme-bold visible.
75-
'relative z-30 shrink grow justify-start max-md:absolute max-md:right-0',
75+
'relative z-30 max-w-none shrink grow justify-start max-md:absolute max-md:right-0',
7676
isOpen ? 'max-md:w-56' : 'max-md:w-[38px]'
7777
)}
7878
>

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,9 @@ export const Button = React.forwardRef<
145145
icon
146146
)
147147
) : null}
148-
{iconOnly ? null : (children ?? label)}
148+
{iconOnly || (!children && !label) ? null : (
149+
<span className="button-content truncate">{children ?? label}</span>
150+
)}
149151
</>
150152
);
151153

packages/gitbook/src/components/primitives/styles.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ export const ButtonStyles = [
3535
'grow-0',
3636
'shrink-0',
3737
'truncate',
38+
'max-w-full',
3839

3940
'disabled:cursor-not-allowed',
4041
'disabled:translate-y-0!',

0 commit comments

Comments
 (0)