fix(ui): do not select already-selected entity

This commit is contained in:
psychedelicious 2024-06-26 21:25:54 +10:00
parent b4c3c940b5
commit 89de04775e

View File

@ -1,7 +1,7 @@
import type { ChakraProps } from '@invoke-ai/ui-library'; import type { ChakraProps } from '@invoke-ai/ui-library';
import { Flex } from '@invoke-ai/ui-library'; import { Flex } from '@invoke-ai/ui-library';
import type { PropsWithChildren } from 'react'; import type { PropsWithChildren } from 'react';
import { memo, useMemo } from 'react'; import { memo, useCallback, useMemo } from 'react';
type Props = PropsWithChildren<{ type Props = PropsWithChildren<{
isSelected: boolean; isSelected: boolean;
@ -16,11 +16,18 @@ export const CanvasEntityContainer = memo(({ isSelected, onSelect, selectedBorde
} }
return 'base.800'; return 'base.800';
}, [isSelected, selectedBorderColor]); }, [isSelected, selectedBorderColor]);
const _onSelect = useCallback(() => {
if (isSelected) {
return;
}
onSelect();
}, [isSelected, onSelect]);
return ( return (
<Flex <Flex
position="relative" position="relative"
gap={2} gap={2}
onClick={onSelect} onClick={_onSelect}
bg={bg} bg={bg}
px={2} px={2}
borderRadius="base" borderRadius="base"