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

Function ThreadScrollButton

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

Source from the content-addressed store, hash-verified

321// TODO: wrapper so we can do the "if isNearBottom then hide" logic, could do this via inline styles perhaps
322// and ditch the wrapper?
323export function ThreadScrollButton({children}: ThreadScrollButtonProps) {
324 let {isNearBottom, scrollToBottom, ...buttonProps} = useContext(ThreadScrollButtonContext);
325 let ref = useRef<HTMLDivElement>(null);
326 let isVisible = !isNearBottom;
327 let isExiting = useExitAnimation(ref, isVisible);
328
329 if (!isVisible && !isExiting) {
330 return null;
331 }
332
333 return (
334 <ButtonContext.Provider
335 value={{slots: {[DEFAULT_SLOT]: {}, scroll: {onPress: scrollToBottom, ...buttonProps}}}}>
336 <ThreadScrollButtonInner domRef={ref} isExiting={isExiting}>
337 {children}
338 </ThreadScrollButtonInner>
339 </ButtonContext.Provider>
340 );
341}
342
343interface ThreadScrollButtonInnerProps {
344 domRef: RefObject<HTMLDivElement | null>;

Callers

nothing calls this directly

Calls 1

useExitAnimationFunction · 0.90

Tested by

no test coverage detected