Skip to content

Commit a33a04d

Browse files
committed
fix: improve drag start handling and native drag preview for macOS
1 parent bca1805 commit a33a04d

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

apps/web/src/common/components/gallery/components/item-component.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,10 @@ export const ItemComponent: React.FC<Props> = props => {
4646
getInitialData: () => ({ type: item.type }),
4747
onDragStart: () => {
4848
setIsDragging(true);
49-
const dataUrl = thumbnailDataUrlRef.current ?? item.thumbnailSrc;
50-
notifyDragStartToWebviewShell(item.type as ShapeType, dataUrl);
49+
const dataUrl = thumbnailDataUrlRef.current;
50+
if (dataUrl) {
51+
notifyDragStartToWebviewShell(item.type as ShapeType, dataUrl);
52+
}
5153
},
5254
onDrop: () => {
5355
setIsDragging(false);
@@ -57,7 +59,7 @@ export const ItemComponent: React.FC<Props> = props => {
5759
// Native drag image from the nested iframe is unreliable on macOS; the
5860
// shell paints its own preview (see drag-bridge.ts), so suppress the
5961
// native one with a 1×1 transparent element.
60-
if (shouldUseMacWebviewDragBridge()) {
62+
if (shouldUseMacWebviewDragBridge() && thumbnailDataUrlRef.current) {
6163
setCustomNativeDragPreview({
6264
getOffset: () => ({ x: 0, y: 0 }),
6365
render({ container }) {

0 commit comments

Comments
 (0)