MCPcopy Create free account
hub / github.com/adobe/react-spectrum / ThreadScrollButton

Function ThreadScrollButton

packages/@react-spectrum/ai/src/Chat.tsx:336–354  ·  view source on GitHub ↗
({children}: ThreadScrollButtonProps)

Source from the content-addressed store, hash-verified

334 * A ThreadScrollButton displays a button to scroll to the bottom of a Chat thread.
335 */
336export function ThreadScrollButton({children}: ThreadScrollButtonProps) {
337 let {isNearBottom, scrollToBottom, ...buttonProps} = useContext(ThreadScrollButtonContext);
338 let ref = useRef<HTMLDivElement>(null);
339 let isVisible = !isNearBottom;
340 let isExiting = useExitAnimation(ref, isVisible);
341
342 if (!isVisible && !isExiting) {
343 return null;
344 }
345
346 return (
347 <ButtonContext.Provider
348 value={{slots: {[DEFAULT_SLOT]: {}, scroll: {onPress: scrollToBottom, ...buttonProps}}}}>
349 <ThreadScrollButtonInner domRef={ref} isExiting={isExiting}>
350 {children}
351 </ThreadScrollButtonInner>
352 </ButtonContext.Provider>
353 );
354}
355
356interface ThreadScrollButtonInnerProps {
357 domRef: RefObject<HTMLDivElement | null>;

Callers

nothing calls this directly

Calls 1

useExitAnimationFunction · 0.90

Tested by

no test coverage detected