diff --git a/.changeset/sweet-yaks-matter.md b/.changeset/sweet-yaks-matter.md new file mode 100644 index 00000000000..a0787d5cbd7 --- /dev/null +++ b/.changeset/sweet-yaks-matter.md @@ -0,0 +1,5 @@ +--- +'@keystone-6/fields-document': patch +--- + +Moved remove button in component block array fields from inside a menu on the drag handle to the right of the drag handle diff --git a/packages/fields-document/src/DocumentEditor/component-blocks/form-from-preview.tsx b/packages/fields-document/src/DocumentEditor/component-blocks/form-from-preview.tsx index d51896c2044..10d8355d407 100644 --- a/packages/fields-document/src/DocumentEditor/component-blocks/form-from-preview.tsx +++ b/packages/fields-document/src/DocumentEditor/component-blocks/form-from-preview.tsx @@ -3,10 +3,10 @@ import { useKeystone } from '@keystone-6/core/admin-ui/context'; import { RelationshipSelect } from '@keystone-6/core/fields/types/relationship/views/RelationshipSelect'; import { Button } from '@keystone-ui/button'; -import { jsx, Stack } from '@keystone-ui/core'; +import { Box, jsx, Stack } from '@keystone-ui/core'; import { FieldContainer, FieldLabel } from '@keystone-ui/fields'; import { memo, useMemo } from 'react'; -import { DragHandle, OrderableItem, OrderableList } from '../primitives/orderable'; +import { DragHandle, OrderableItem, OrderableList, RemoveButton } from '../primitives/orderable'; import { ArrayField, ComponentSchema, @@ -185,14 +185,19 @@ export const FormValueContentFromPreviewProps = memo(function FormValueContentFr }); const OrderableItemInForm = memo(function OrderableItemInForm( - props: GenericPreviewProps & { elementKey: string } + props: GenericPreviewProps & { + elementKey: string; + } ) { return ( - +
- - {isNonChildFieldPreviewProps(props) && } + +
+ + {isNonChildFieldPreviewProps(props) && } +
); }); diff --git a/packages/fields-document/src/DocumentEditor/primitives/orderable.tsx b/packages/fields-document/src/DocumentEditor/primitives/orderable.tsx index 050230168f4..b39d59a63d3 100644 --- a/packages/fields-document/src/DocumentEditor/primitives/orderable.tsx +++ b/packages/fields-document/src/DocumentEditor/primitives/orderable.tsx @@ -1,6 +1,6 @@ /** @jsxRuntime classic */ /** @jsx jsx */ -import { Box, jsx } from '@keystone-ui/core'; +import { jsx } from '@keystone-ui/core'; import { useCallback, useEffect, useMemo, useRef } from 'react'; import { useSensors, @@ -20,8 +20,8 @@ import { } from '@dnd-kit/sortable'; import { createContext, ReactNode, useContext } from 'react'; import { restrictToVerticalAxis } from '@dnd-kit/modifiers'; -import { Popover } from '@keystone-ui/popover'; -import { ToolbarButton } from '.'; +import { Button } from '@keystone-ui/button'; +import { Trash2Icon } from '@keystone-ui/icons/icons/Trash2Icon'; const RemoveContext = createContext void)>(null); @@ -131,8 +131,7 @@ export function OrderableItem(props: { elementKey: string; children: ReactNode } style={{ pointerEvents: isDragging ? 'none' : undefined, transform: `scale(${isDragging ? '1.02' : '1'})`, - border: '1px solid #DADEEB', - boxShadow: '0px 1px 4px rgba(9, 30, 66, 0.04)', + border: '1px solid #DFDFE7', }} css={{ backgroundColor: 'white', @@ -148,67 +147,53 @@ export function OrderableItem(props: { elementKey: string; children: ReactNode } ); } -export function DragHandle() { +export function RemoveButton() { const sortable = useContext(DragHandleListenersContext); - if (sortable === null) { - throw new Error('Must use OrderableItem above DragHandle'); + const onRemove = useContext(RemoveContext); + if (sortable === null || onRemove === null) { + throw new Error('Must use OrderableItem above RemoveButton'); } - const onRemove = useContext(RemoveContext); - if (onRemove === null) { + return ( + + ); +} + +export function DragHandle() { + const sortable = useContext(DragHandleListenersContext); + if (sortable === null) { throw new Error('Must use OrderableItem above DragHandle'); } return ( - - { - return ( -
- -
- ); - }} - > - - { - onRemove(sortable.index); - }} - > - Remove - - -
-
+ ); } export const dragIcon = ( - - - + + + + + );