fix(ui): boards cut off when search open

This commit is contained in:
psychedelicious 2024-07-15 11:52:40 +10:00
parent 28e79c4c5e
commit 24bf1ea65a
2 changed files with 60 additions and 51 deletions

View File

@ -1,4 +1,4 @@
import { Flex, Text } from '@invoke-ai/ui-library'; import { Box, Flex, Text } from '@invoke-ai/ui-library';
import { EMPTY_ARRAY } from 'app/store/constants'; import { EMPTY_ARRAY } from 'app/store/constants';
import { useAppSelector } from 'app/store/storeHooks'; import { useAppSelector } from 'app/store/storeHooks';
import { overlayScrollbarsParams } from 'common/components/OverlayScrollbars/constants'; import { overlayScrollbarsParams } from 'common/components/OverlayScrollbars/constants';
@ -40,9 +40,41 @@ const BoardsList = () => {
return ( return (
<> <>
<Flex flexDir="column" gap={2} borderRadius="base" maxHeight="100%"> <Box position="relative" w="full" h="full">
<OverlayScrollbarsComponent defer style={overlayScrollbarsStyles} options={overlayScrollbarsParams.options}> <Box position="absolute" top={0} right={0} bottom={0} left={0}>
{allowPrivateBoards && ( <OverlayScrollbarsComponent defer style={overlayScrollbarsStyles} options={overlayScrollbarsParams.options}>
{allowPrivateBoards && (
<Flex direction="column" gap={1}>
<Flex
position="sticky"
w="full"
justifyContent="space-between"
alignItems="center"
ps={2}
pb={1}
pt={2}
zIndex={1}
top={0}
bg="base.900"
>
<Text fontSize="md" fontWeight="semibold" userSelect="none">
{t('boards.private')}
</Text>
<AddBoardButton isPrivateBoard={true} />
</Flex>
<Flex direction="column" gap={1}>
<NoBoardBoard isSelected={selectedBoardId === 'none'} />
{filteredPrivateBoards.map((board) => (
<GalleryBoard
board={board}
isSelected={selectedBoardId === board.board_id}
setBoardToDelete={setBoardToDelete}
key={board.board_id}
/>
))}
</Flex>
</Flex>
)}
<Flex direction="column" gap={1}> <Flex direction="column" gap={1}>
<Flex <Flex
position="sticky" position="sticky"
@ -50,19 +82,20 @@ const BoardsList = () => {
justifyContent="space-between" justifyContent="space-between"
alignItems="center" alignItems="center"
ps={2} ps={2}
py={1} pb={1}
pt={2}
zIndex={1} zIndex={1}
top={0} top={0}
bg="base.900" bg="base.900"
> >
<Text fontSize="md" fontWeight="semibold" userSelect="none"> <Text fontSize="md" fontWeight="semibold" userSelect="none">
{t('boards.private')} {allowPrivateBoards ? t('boards.shared') : t('boards.boards')}
</Text> </Text>
<AddBoardButton isPrivateBoard={true} /> <AddBoardButton isPrivateBoard={false} />
</Flex> </Flex>
<Flex direction="column" gap={1}> <Flex direction="column" gap={1}>
<NoBoardBoard isSelected={selectedBoardId === 'none'} /> {!allowPrivateBoards && <NoBoardBoard isSelected={selectedBoardId === 'none'} />}
{filteredPrivateBoards.map((board) => ( {filteredSharedBoards.map((board) => (
<GalleryBoard <GalleryBoard
board={board} board={board}
isSelected={selectedBoardId === board.board_id} isSelected={selectedBoardId === board.board_id}
@ -72,38 +105,9 @@ const BoardsList = () => {
))} ))}
</Flex> </Flex>
</Flex> </Flex>
)} </OverlayScrollbarsComponent>
<Flex direction="column" gap={1} pb={2}> </Box>
<Flex </Box>
position="sticky"
w="full"
justifyContent="space-between"
alignItems="center"
ps={2}
py={1}
zIndex={1}
top={0}
bg="base.900"
>
<Text fontSize="md" fontWeight="semibold" userSelect="none">
{allowPrivateBoards ? t('boards.shared') : t('boards.boards')}
</Text>
<AddBoardButton isPrivateBoard={false} />
</Flex>
<Flex direction="column" gap={1}>
{!allowPrivateBoards && <NoBoardBoard isSelected={selectedBoardId === 'none'} />}
{filteredSharedBoards.map((board) => (
<GalleryBoard
board={board}
isSelected={selectedBoardId === board.board_id}
setBoardToDelete={setBoardToDelete}
key={board.board_id}
/>
))}
</Flex>
</Flex>
</OverlayScrollbarsComponent>
</Flex>
<DeleteBoardModal boardToDelete={boardToDelete} setBoardToDelete={setBoardToDelete} /> <DeleteBoardModal boardToDelete={boardToDelete} setBoardToDelete={setBoardToDelete} />
</> </>
); );

View File

@ -16,6 +16,7 @@ import { GalleryHeader } from 'features/gallery/components/GalleryHeader';
import { galleryViewChanged } from 'features/gallery/store/gallerySlice'; import { galleryViewChanged } from 'features/gallery/store/gallerySlice';
import ResizeHandle from 'features/ui/components/tabs/ResizeHandle'; import ResizeHandle from 'features/ui/components/tabs/ResizeHandle';
import { usePanel, type UsePanelOptions } from 'features/ui/hooks/usePanel'; import { usePanel, type UsePanelOptions } from 'features/ui/hooks/usePanel';
import type { CSSProperties } from 'react';
import { memo, useCallback, useMemo, useRef } from 'react'; import { memo, useCallback, useMemo, useRef } from 'react';
import { useTranslation } from 'react-i18next'; import { useTranslation } from 'react-i18next';
import { PiMagnifyingGlassBold } from 'react-icons/pi'; import { PiMagnifyingGlassBold } from 'react-icons/pi';
@ -29,13 +30,15 @@ import GalleryImageGrid from './ImageGrid/GalleryImageGrid';
import { GalleryPagination } from './ImageGrid/GalleryPagination'; import { GalleryPagination } from './ImageGrid/GalleryPagination';
import { GallerySearch } from './ImageGrid/GallerySearch'; import { GallerySearch } from './ImageGrid/GallerySearch';
const baseStyles: ChakraProps['sx'] = { const COLLAPSE_STYLES: CSSProperties = { flexShrink: 0, minHeight: 0 };
const BASE_STYLES: ChakraProps['sx'] = {
fontWeight: 'semibold', fontWeight: 'semibold',
fontSize: 'sm', fontSize: 'sm',
color: 'base.300', color: 'base.300',
}; };
const selectedStyles: ChakraProps['sx'] = { const SELECTED_STYLES: ChakraProps['sx'] = {
borderColor: 'base.800', borderColor: 'base.800',
borderBottomColor: 'base.900', borderBottomColor: 'base.900',
color: 'invokeBlue.300', color: 'invokeBlue.300',
@ -110,11 +113,13 @@ const ImageGalleryContent = () => {
onExpand={boardsListPanel.onExpand} onExpand={boardsListPanel.onExpand}
collapsible collapsible
> >
<Collapse in={boardSearchDisclosure.isOpen}> <Flex flexDir="column" w="full" h="full">
<BoardsSearch /> <Collapse in={boardSearchDisclosure.isOpen} style={COLLAPSE_STYLES}>
</Collapse> <BoardsSearch />
<Divider pt={2} /> </Collapse>
<BoardsList /> <Divider pt={2} />
<BoardsList />
</Flex>
</Panel> </Panel>
<ResizeHandle <ResizeHandle
id="gallery-panel-handle" id="gallery-panel-handle"
@ -125,10 +130,10 @@ const ImageGalleryContent = () => {
<Flex flexDirection="column" alignItems="center" justifyContent="space-between" h="full" w="full"> <Flex flexDirection="column" alignItems="center" justifyContent="space-between" h="full" w="full">
<Tabs index={galleryView === 'images' ? 0 : 1} variant="enclosed" display="flex" flexDir="column" w="full"> <Tabs index={galleryView === 'images' ? 0 : 1} variant="enclosed" display="flex" flexDir="column" w="full">
<TabList gap={2} fontSize="sm" borderColor="base.800"> <TabList gap={2} fontSize="sm" borderColor="base.800">
<Tab sx={baseStyles} _selected={selectedStyles} onClick={handleClickImages} data-testid="images-tab"> <Tab sx={BASE_STYLES} _selected={SELECTED_STYLES} onClick={handleClickImages} data-testid="images-tab">
{t('parameters.images')} {t('parameters.images')}
</Tab> </Tab>
<Tab sx={baseStyles} _selected={selectedStyles} onClick={handleClickAssets} data-testid="assets-tab"> <Tab sx={BASE_STYLES} _selected={SELECTED_STYLES} onClick={handleClickAssets} data-testid="assets-tab">
{t('gallery.assets')} {t('gallery.assets')}
</Tab> </Tab>
<Spacer /> <Spacer />
@ -157,7 +162,7 @@ const ImageGalleryContent = () => {
</TabList> </TabList>
</Tabs> </Tabs>
<Box w="full"> <Box w="full">
<Collapse in={searchDisclosure.isOpen}> <Collapse in={searchDisclosure.isOpen} style={COLLAPSE_STYLES}>
<Box w="full" pt={2}> <Box w="full" pt={2}>
<GallerySearch /> <GallerySearch />
</Box> </Box>