Skip to content

Commit 0727190

Browse files
committed
fix: Add forwardRef to LLMButtons
1 parent 8c7bf56 commit 0727190

File tree

1 file changed

+34
-35
lines changed
  • apify-docs-theme/src/theme/LLMButtons

1 file changed

+34
-35
lines changed

apify-docs-theme/src/theme/LLMButtons/index.jsx

Lines changed: 34 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -186,41 +186,39 @@ function getButtonText({ status }) {
186186
}
187187
}
188188

189-
const MenuBase = ({
190-
children,
191-
ref,
192-
copyingStatus,
193-
setCopyingStatus,
194-
chevronIconRef,
195-
...props
196-
}) => (
197-
<div ref={ref} className={styles.llmButtonWrapper}>
198-
<div className={styles.llmButton}>
199-
<div
200-
className={styles.copyUpIconWrapper}
201-
onClick={() => onCopyAsMarkdownClick({ setCopyingStatus })}
202-
>
203-
{copyingStatus === 'loading' && <LoaderIcon size={16} />}
204-
{copyingStatus === 'copied' && <CheckIcon size={16} />}
205-
{copyingStatus === 'idle' && <CopyIcon size={16} />}
206-
</div>
207-
<Text
208-
size="regular"
209-
onClick={() => onCopyAsMarkdownClick({ setCopyingStatus })}
210-
className={styles.llmButtonText}
211-
>
212-
{getButtonText({ status: copyingStatus })}
213-
</Text>
214-
<div {...props} className={styles.chevronIconWrapper}>
215-
<ChevronDownIcon
216-
size="16"
217-
color={theme.color.neutral.icon}
218-
className={styles.chevronIcon}
219-
ref={chevronIconRef}
220-
/>
189+
const MenuBase = React.forwardRef(
190+
(
191+
{ children, copyingStatus, setCopyingStatus, chevronIconRef, ...props },
192+
ref,
193+
) => (
194+
<div ref={ref} className={styles.llmButtonWrapper}>
195+
<div className={styles.llmButton}>
196+
<div
197+
className={styles.copyUpIconWrapper}
198+
onClick={() => onCopyAsMarkdownClick({ setCopyingStatus })}
199+
>
200+
{copyingStatus === 'loading' && <LoaderIcon size={16} />}
201+
{copyingStatus === 'copied' && <CheckIcon size={16} />}
202+
{copyingStatus === 'idle' && <CopyIcon size={16} />}
203+
</div>
204+
<Text
205+
size="regular"
206+
onClick={() => onCopyAsMarkdownClick({ setCopyingStatus })}
207+
className={styles.llmButtonText}
208+
>
209+
{getButtonText({ status: copyingStatus })}
210+
</Text>
211+
<div {...props} className={styles.chevronIconWrapper}>
212+
<ChevronDownIcon
213+
size="16"
214+
color={theme.color.neutral.icon}
215+
className={styles.chevronIcon}
216+
ref={chevronIconRef}
217+
/>
218+
</div>
221219
</div>
222220
</div>
223-
</div>
221+
),
224222
);
225223

226224
const Option = ({ Icon, label, description, showExternalIcon }) => (
@@ -278,14 +276,15 @@ export default function LLMButtons({ isApiReferencePage = false }) {
278276
)
279277
}
280278
components={{
281-
MenuBase: (props) => (
279+
MenuBase: React.forwardRef((props, ref) => (
282280
<MenuBase
283281
copyingStatus={copyingStatus}
284282
setCopyingStatus={setCopyingStatus}
285283
chevronIconRef={chevronIconRef}
284+
ref={ref}
286285
{...props}
287286
/>
288-
),
287+
)),
289288
}}
290289
onSelect={onMenuOptionClick}
291290
options={DROPDOWN_OPTIONS}

0 commit comments

Comments
 (0)