Skip to content

Commit 6987cea

Browse files
authored
Merge pull request #433 from DiegoSouzaPW/feature/SlotCloneError
Check the render method of SlotClone. #432
2 parents 15ce035 + 44bda15 commit 6987cea

File tree

3 files changed

+107
-94
lines changed

3 files changed

+107
-94
lines changed

app/components/chat/Messages.client.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,8 @@ export const Messages = React.forwardRef<HTMLDivElement, MessagesProps>((props:
7373
</div>
7474
{!isUserMessage && (
7575
<div className="flex gap-2 flex-col lg:flex-row">
76-
<WithTooltip tooltip="Revert to this message">
77-
{messageId && (
76+
{messageId && (
77+
<WithTooltip tooltip="Revert to this message">
7878
<button
7979
onClick={() => handleRewind(messageId)}
8080
key="i-ph:arrow-u-up-left"
@@ -83,8 +83,8 @@ export const Messages = React.forwardRef<HTMLDivElement, MessagesProps>((props:
8383
'text-xl text-bolt-elements-textSecondary hover:text-bolt-elements-textPrimary transition-colors',
8484
)}
8585
/>
86-
)}
87-
</WithTooltip>
86+
</WithTooltip>
87+
)}
8888

8989
<WithTooltip tooltip="Fork chat from this message">
9090
<button

app/components/ui/IconButton.tsx

Lines changed: 41 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { memo } from 'react';
1+
import { memo, forwardRef, type ForwardedRef } from 'react';
22
import { classNames } from '~/utils/classNames';
33

44
type IconSize = 'sm' | 'md' | 'lg' | 'xl' | 'xxl';
@@ -25,41 +25,48 @@ type IconButtonWithChildrenProps = {
2525

2626
type IconButtonProps = IconButtonWithoutChildrenProps | IconButtonWithChildrenProps;
2727

28+
// Componente IconButton com suporte a refs
2829
export const IconButton = memo(
29-
({
30-
icon,
31-
size = 'xl',
32-
className,
33-
iconClassName,
34-
disabledClassName,
35-
disabled = false,
36-
title,
37-
onClick,
38-
children,
39-
}: IconButtonProps) => {
40-
return (
41-
<button
42-
className={classNames(
43-
'flex items-center text-bolt-elements-item-contentDefault bg-transparent enabled:hover:text-bolt-elements-item-contentActive rounded-md p-1 enabled:hover:bg-bolt-elements-item-backgroundActive disabled:cursor-not-allowed',
44-
{
45-
[classNames('opacity-30', disabledClassName)]: disabled,
46-
},
47-
className,
48-
)}
49-
title={title}
50-
disabled={disabled}
51-
onClick={(event) => {
52-
if (disabled) {
53-
return;
54-
}
30+
forwardRef(
31+
(
32+
{
33+
icon,
34+
size = 'xl',
35+
className,
36+
iconClassName,
37+
disabledClassName,
38+
disabled = false,
39+
title,
40+
onClick,
41+
children,
42+
}: IconButtonProps,
43+
ref: ForwardedRef<HTMLButtonElement>,
44+
) => {
45+
return (
46+
<button
47+
ref={ref}
48+
className={classNames(
49+
'flex items-center text-bolt-elements-item-contentDefault bg-transparent enabled:hover:text-bolt-elements-item-contentActive rounded-md p-1 enabled:hover:bg-bolt-elements-item-backgroundActive disabled:cursor-not-allowed',
50+
{
51+
[classNames('opacity-30', disabledClassName)]: disabled,
52+
},
53+
className,
54+
)}
55+
title={title}
56+
disabled={disabled}
57+
onClick={(event) => {
58+
if (disabled) {
59+
return;
60+
}
5561

56-
onClick?.(event);
57-
}}
58-
>
59-
{children ? children : <div className={classNames(icon, getIconSize(size), iconClassName)}></div>}
60-
</button>
61-
);
62-
},
62+
onClick?.(event);
63+
}}
64+
>
65+
{children ? children : <div className={classNames(icon, getIconSize(size), iconClassName)}></div>}
66+
</button>
67+
);
68+
},
69+
),
6370
);
6471

6572
function getIconSize(size: IconSize) {

app/components/ui/Tooltip.tsx

Lines changed: 62 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
import * as Tooltip from '@radix-ui/react-tooltip';
2+
import { forwardRef, type ForwardedRef, type ReactElement } from 'react';
23

34
interface TooltipProps {
45
tooltip: React.ReactNode;
5-
children: React.ReactNode;
6+
children: ReactElement;
67
sideOffset?: number;
78
className?: string;
89
arrowClassName?: string;
@@ -12,62 +13,67 @@ interface TooltipProps {
1213
delay?: number;
1314
}
1415

15-
const WithTooltip = ({
16-
tooltip,
17-
children,
18-
sideOffset = 5,
19-
className = '',
20-
arrowClassName = '',
21-
tooltipStyle = {},
22-
position = 'top',
23-
maxWidth = 250,
24-
delay = 0,
25-
}: TooltipProps) => {
26-
return (
27-
<Tooltip.Root delayDuration={delay}>
28-
<Tooltip.Trigger asChild>{children}</Tooltip.Trigger>
29-
<Tooltip.Portal>
30-
<Tooltip.Content
31-
side={position}
32-
className={`
33-
z-[2000]
34-
px-2.5
35-
py-1.5
36-
max-h-[300px]
37-
select-none
38-
rounded-md
39-
bg-bolt-elements-background-depth-3
40-
text-bolt-elements-textPrimary
41-
text-sm
42-
leading-tight
43-
shadow-lg
44-
animate-in
45-
fade-in-0
46-
zoom-in-95
47-
data-[state=closed]:animate-out
48-
data-[state=closed]:fade-out-0
49-
data-[state=closed]:zoom-out-95
50-
${className}
51-
`}
52-
sideOffset={sideOffset}
53-
style={{
54-
maxWidth,
55-
...tooltipStyle,
56-
}}
57-
>
58-
<div className="break-words">{tooltip}</div>
59-
<Tooltip.Arrow
16+
const WithTooltip = forwardRef(
17+
(
18+
{
19+
tooltip,
20+
children,
21+
sideOffset = 5,
22+
className = '',
23+
arrowClassName = '',
24+
tooltipStyle = {},
25+
position = 'top',
26+
maxWidth = 250,
27+
delay = 0,
28+
}: TooltipProps,
29+
_ref: ForwardedRef<HTMLElement>,
30+
) => {
31+
return (
32+
<Tooltip.Root delayDuration={delay}>
33+
<Tooltip.Trigger asChild>{children}</Tooltip.Trigger>
34+
<Tooltip.Portal>
35+
<Tooltip.Content
36+
side={position}
6037
className={`
61-
fill-bolt-elements-background-depth-3
62-
${arrowClassName}
38+
z-[2000]
39+
px-2.5
40+
py-1.5
41+
max-h-[300px]
42+
select-none
43+
rounded-md
44+
bg-bolt-elements-background-depth-3
45+
text-bolt-elements-textPrimary
46+
text-sm
47+
leading-tight
48+
shadow-lg
49+
animate-in
50+
fade-in-0
51+
zoom-in-95
52+
data-[state=closed]:animate-out
53+
data-[state=closed]:fade-out-0
54+
data-[state=closed]:zoom-out-95
55+
${className}
6356
`}
64-
width={12}
65-
height={6}
66-
/>
67-
</Tooltip.Content>
68-
</Tooltip.Portal>
69-
</Tooltip.Root>
70-
);
71-
};
57+
sideOffset={sideOffset}
58+
style={{
59+
maxWidth,
60+
...tooltipStyle,
61+
}}
62+
>
63+
<div className="break-words">{tooltip}</div>
64+
<Tooltip.Arrow
65+
className={`
66+
fill-bolt-elements-background-depth-3
67+
${arrowClassName}
68+
`}
69+
width={12}
70+
height={6}
71+
/>
72+
</Tooltip.Content>
73+
</Tooltip.Portal>
74+
</Tooltip.Root>
75+
);
76+
},
77+
);
7278

7379
export default WithTooltip;

0 commit comments

Comments
 (0)