Streamfield: don't render values container unless it has values

This commit is contained in:
Alex Gleason 2022-05-05 15:59:36 -05:00
parent 9abe924e92
commit b401af2950
No known key found for this signature in database
GPG key ID: 7211D1F99744FBB7

View file

@ -65,22 +65,24 @@ const Streamfield: React.FC<IStreamfield> = ({
{hint && <Text size='xs' theme='muted'>{hint}</Text>}
</Stack>
<Stack>
{values.map((value, i) => (
<HStack space={2} alignItems='center'>
<Component key={i} onChange={handleChange(i)} value={value} />
{onRemoveItem && (
<IconButton
iconClassName='w-4 h-4'
className='bg-transparent text-gray-400 hover:text-gray-600'
src={require('@tabler/icons/icons/x.svg')}
onClick={() => onRemoveItem(i)}
title={intl.formatMessage(messages.remove)}
/>
)}
</HStack>
))}
</Stack>
{(values.length > 0) && (
<Stack>
{values.map((value, i) => (
<HStack space={2} alignItems='center'>
<Component key={i} onChange={handleChange(i)} value={value} />
{onRemoveItem && (
<IconButton
iconClassName='w-4 h-4'
className='bg-transparent text-gray-400 hover:text-gray-600'
src={require('@tabler/icons/icons/x.svg')}
onClick={() => onRemoveItem(i)}
title={intl.formatMessage(messages.remove)}
/>
)}
</HStack>
))}
</Stack>
)}
{onAddItem && (
<Button