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

Function ThreadScrollButton

packages/@react-spectrum/ai/src/Chat.tsx:399–417  ·  view source on GitHub ↗

* A ThreadScrollButton displays a button to scroll to the bottom of a Chat thread.

({children}: ThreadScrollButtonProps)

Source from the content-addressed store, hash-verified

397 * A ThreadScrollButton displays a button to scroll to the bottom of a Chat thread.
398 */
399function ThreadScrollButton({children}: ThreadScrollButtonProps) {
400 let {isNearBottom, scrollToBottom, ...buttonProps} = useContext(ThreadScrollButtonContext);
401 let ref = useRef<HTMLDivElement>(null);
402 let isVisible = !isNearBottom;
403 let isExiting = useExitAnimation(ref, isVisible);
404
405 if (!isVisible && !isExiting) {
406 return null;
407 }
408
409 return (
410 <ButtonContext.Provider
411 value={{slots: {[DEFAULT_SLOT]: {}, scroll: {onPress: scrollToBottom, ...buttonProps}}}}>
412 <ThreadScrollButtonInner domRef={ref} isExiting={isExiting}>
413 {children}
414 </ThreadScrollButtonInner>
415 </ButtonContext.Provider>
416 );
417}
418
419interface ThreadScrollButtonInnerProps {
420 domRef: RefObject<HTMLDivElement | null>;

Callers

nothing calls this directly

Calls 1

useExitAnimationFunction · 0.90

Tested by

no test coverage detected