Skip to content

Commit

Permalink
Fix incorrect drop indicator showing when two list views are open. Re…
Browse files Browse the repository at this point in the history
…move duplicate ids
  • Loading branch information
talldan committed Jul 13, 2021
1 parent a6bdb3f commit d1ab212
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 11 deletions.
2 changes: 0 additions & 2 deletions packages/block-editor/src/components/block-draggable/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ const BlockDraggable = ( {
cloneClassname,
onDragStart,
onDragEnd,
elementId,
} ) => {
const { srcRootClientId, isDraggable, icon } = useSelect(
( select ) => {
Expand Down Expand Up @@ -75,7 +74,6 @@ const BlockDraggable = ( {
return (
<Draggable
cloneClassname={ cloneClassname }
elementId={ elementId }
__experimentalTransferDataType="wp-blocks"
transferData={ transferData }
onDragStart={ ( event ) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,7 @@ const ListViewBlockContents = forwardRef(
} );

return (
<BlockDraggable
clientIds={ [ block.clientId ] }
elementId={ `list-view-block-${ block.clientId }` }
>
<BlockDraggable clientIds={ [ block.clientId ] }>
{ ( { draggable, onDragStart, onDragEnd } ) =>
__experimentalFeatures ? (
<ListViewBlockSlot
Expand Down
10 changes: 5 additions & 5 deletions packages/block-editor/src/components/list-view/drop-indicator.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,21 @@ export default function ListViewDropIndicator( {
return [];
}

const ownerDocument = listViewRef.current.ownerDocument;

// The rootClientId will be defined whenever dropping into inner
// block lists, but is undefined when dropping at the root level.
const _rootBlockElement = rootClientId
? ownerDocument.getElementById(
`list-view-block-${ rootClientId }`
? listViewRef.current.querySelector(
`[data-block="${ rootClientId }"]`
)
: undefined;

// The clientId represents the sibling block, the dragged block will
// usually be inserted adjacent to it. It will be undefined when
// dropping a block into an empty block list.
const _blockElement = clientId
? ownerDocument.getElementById( `list-view-block-${ clientId }` )
? listViewRef.current.querySelector(
`[data-block="${ clientId }"]`
)
: undefined;

return [ _rootBlockElement, _blockElement ];
Expand Down

0 comments on commit d1ab212

Please sign in to comment.