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

Zoom Out: Show a preview when dragging and dropping patterns from the inserter. #61511

Closed
wants to merge 3 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
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,15 @@ const InserterDraggableBlocks = ( {
stopDragging();
} }
__experimentalDragComponent={
<BlockDraggableChip
count={ blocks.length }
icon={ icon || ( ! pattern && blockTypeIcon ) }
isPattern={ !! pattern }
/>
pattern ? (
false // Setting dragComponent explicitly to false, so that the browser handles the drag image.
) : (
<BlockDraggableChip
count={ blocks.length }
icon={ icon || ( ! pattern && blockTypeIcon ) }
isPattern={ !! pattern }
/>
)
}
>
{ ( { onDraggableStart, onDraggableEnd } ) => {
Expand Down
1 change: 1 addition & 0 deletions packages/components/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
### Internal

- Replaced `classnames` package with the faster and smaller `clsx` package ([#61138](https://github.com/WordPress/gutenberg/pull/61138)).
- Zoom Out: Show a preview when dragging and dropping patterns from the inserter. ([#61511](https://github.com/WordPress/gutenberg/pull/61511))

### Enhancements
- `PaletteEdit`: Use consistent spacing and metrics. ([#61368](https://github.com/WordPress/gutenberg/pull/61368)).
Expand Down
5 changes: 5 additions & 0 deletions packages/components/src/draggable/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,11 @@ export function Draggable( {
JSON.stringify( transferData )
);

// If dragComponent is explicitly set to false then let the browser handle the drag image.
if ( dragComponent === false ) {
return;
}

const cloneWrapper = ownerDocument.createElement( 'div' );
// Reset position to 0,0. Natural stacking order will position this lower, even with a transform otherwise.
cloneWrapper.style.top = '0';
Expand Down
Loading