Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

List View: Update draggable chip to resemble the list view item when dragged #49820

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion packages/block-editor/src/components/block-draggable/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,14 @@ import useScrollWhenDragging from './use-scroll-when-dragging';
import { store as blockEditorStore } from '../../store';

const BlockDraggable = ( {
appendToOwnerDocument,
children,
clientIds,
cloneClassname,
elementId,
onDragStart,
onDragEnd,
__experimentalDragComponent,
} ) => {
const { srcRootClientId, isDraggable, icon } = useSelect(
( select ) => {
Expand Down Expand Up @@ -73,6 +76,7 @@ const BlockDraggable = ( {

return (
<Draggable
appendToOwnerDocument={ appendToOwnerDocument }
cloneClassname={ cloneClassname }
__experimentalTransferDataType="wp-blocks"
transferData={ transferData }
Expand Down Expand Up @@ -102,8 +106,18 @@ const BlockDraggable = ( {
}
} }
__experimentalDragComponent={
<BlockDraggableChip count={ clientIds.length } icon={ icon } />
// Check against `undefined` so that `null` can be used to disable
// the default drag component.
__experimentalDragComponent !== undefined ? (
__experimentalDragComponent
) : (
<BlockDraggableChip
count={ clientIds.length }
icon={ icon }
/>
)
}
elementId={ elementId }
>
{ ( { onDraggableStart, onDraggableEnd } ) => {
return children( {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,12 @@ const ListViewBlockContents = forwardRef(
[]
);

const { AdditionalBlockContent, insertedBlock, setInsertedBlock } =
useListViewContext();
const {
AdditionalBlockContent,
insertedBlock,
listViewInstanceId,
setInsertedBlock,
} = useListViewContext();

const isBlockMoveTarget =
blockMovingClientId && selectedBlockInBlockEditor === clientId;
Expand All @@ -74,7 +78,12 @@ const ListViewBlockContents = forwardRef(
setInsertedBlock={ setInsertedBlock }
/>
) }
<BlockDraggable clientIds={ draggableClientIds }>
<BlockDraggable
appendToOwnerDocument
clientIds={ draggableClientIds }
__experimentalDragComponent={ null }
elementId={ `list-view-${ listViewInstanceId }-block-${ clientId }` }
>
{ ( { draggable, onDragStart, onDragEnd } ) => (
<ListViewBlockSelectButton
ref={ ref }
Expand Down
23 changes: 23 additions & 0 deletions packages/block-editor/src/components/list-view/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,29 @@
line-height: 0;
}

&[id^="clone-"] {
align-items: center;
display: flex;
height: 36px;
background: $white;
border: 1px solid $gray-400;
border-radius: $radius-block-ui;
opacity: 0.75;

.block-editor-list-view-block__contents-cell {
flex: 1;
}

&.is-selected td {
background: $white;

.block-editor-list-view-block-select-button,
.components-button.has-icon {
color: inherit;
}
}
}

.block-editor-list-view-block-select-button__images {
display: flex;
}
Expand Down