Invoke is a leading creative engine that uses image and video generation models to empower professionals, artists, and enthusiasts to generate and create visual media using the latest AI-driven technologies. The solution offers an industry-leading application interface, and serves as the foundation for multiple commercial products.
TypeScript ai-artartificial-intelligencegenerative-artimage-generationimg2imginpaintinglatent-diffusionlinuxmacosoutpaintingstable-diffusiontxt2imgwindows
fix(ui): scroll resizable textarea through ScrollArea
joshistoastf8b174a32bf2
diff --git a/invokeai/frontend/webv2/src/workbench/components/ui/ResizableTextarea.browser.test.tsx b/invokeai/frontend/webv2/src/workbench/components/ui/ResizableTextarea.browser.test.tsxindex 1cf3157858..2d84015752 100644--- a/invokeai/frontend/webv2/src/workbench/components/ui/ResizableTextarea.browser.test.tsx+++ b/invokeai/frontend/webv2/src/workbench/components/ui/ResizableTextarea.browser.test.tsx@@ -69,6 +69,24 @@ describe('ResizableTextarea', () => {expect(handle.hasAttribute('aria-valuemax')).toBe(false);});+ it('scrolls through the ScrollArea viewport instead of a native scrollbar', async () => {+ const { textarea } = await renderTextarea(140);++ expect(textarea.dataset.part).toBe('viewport');+ expect(getComputedStyle(textarea).scrollbarWidth).toBe('none');++ await act(() => {+ textarea.value = Array.from({ length: 50 }, (_, index) => `line ${index}`).join('\n');+ textarea.dispatchEvent(new Event('input', { bubbles: true }));+ textarea.scrollTop = 100;+ });++ const scrollbar = host!.querySelector<HTMLElement>('[data-part="scrollbar"]')!;++ await expect.poll(() => scrollbar.hasAttribute('data-overflow-y')).toBe(true);+ await expect.poll(() => host!.querySelector<HTMLElement>('[data-part="thumb"]')!.clientHeight).toBeGreaterThan(0);+ });+it('retains bounded End behavior when a maximum is supplied', async () => {const { handle, textarea } = await renderTextarea(140);diff --git a/invokeai/frontend/webv2/src/workbench/components/ui/ResizableTextarea.tsx b/invokeai/frontend/webv2/src/workbench/components/ui/ResizableTextarea.tsxindex 99498f3e02..ccfce15cd0 100644--- a/invokeai/frontend/webv2/src/workbench/components/ui/ResizableTextarea.tsx+++ b/invokeai/frontend/webv2/src/workbench/components/ui/ResizableTextarea.tsx@@ -7,7 +7,7 @@ import type {ReactNode,} from 'react';-import { Box, Textarea } from '@chakra-ui/react';+import { Box, ScrollArea, Textarea } from '@chakra-ui/react';import { useCallback, useState } from 'react';type TextareaProps = ComponentProps<typeof Textarea>;@@ -135,14 +135,23 @@ export const ResizableTextarea = ({return (<Box position="relative">{underlay}- <Textarea- ref={textareaRef}+ <ScrollArea.Root+ borderRadius="l2"h={`${displayHeightPx}px`}- position={underlay ? 'relative' : textareaProps.position}- resize="none"- zIndex={underlay ? 1 : textareaProps.zIndex}- {...textareaProps}- />+ size="xs"+ variant="hover"+ zIndex={underlay ? 1 : undefined}+ >+ <ScrollArea.Viewport asChild>+ <Textarea ref={textareaRef} resize="none" {...textareaProps} />+ </ScrollArea.Viewport>+ {/* zag skips scrollbar re-measurement entirely without a content element;+ the textarea is the viewport, so park an empty one for its observer. */}+ <ScrollArea.Content h="0" minW="0" overflow="hidden" position="absolute" />+ <ScrollArea.Scrollbar>+ <ScrollArea.Thumb />+ </ScrollArea.Scrollbar>+ </ScrollArea.Root><Boxaria-label={resizeHandleAriaLabel}aria-orientation="horizontal"