Skip to content

Commit

Permalink
[chore] Drag&Drop context: extra check for the object type (#2379)
Browse files Browse the repository at this point in the history
Signed-off-by: Ihor Dykhta <dikhta.igor@gmail.com>
  • Loading branch information
igorDykhta committed Oct 19, 2023
1 parent a958586 commit 5c16027
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/components/src/dnd-context.tsx
@@ -1,6 +1,7 @@
import React, {useCallback, useMemo, useState, PropsWithChildren} from 'react';
import styled from 'styled-components';
import {DndContext as DndKitContext, DragOverlay} from '@dnd-kit/core';
import Console from 'global/console';
import {useDispatch} from 'react-redux';
import {
DND_EMPTY_MODIFIERS,
Expand Down Expand Up @@ -120,8 +121,17 @@ function DndContextFactory(

const onDragStart = useCallback(
event => {
onLayerDragStart(event);
onEffectDragStart(event);
const activeType = event.active.data?.current?.type;
switch (activeType) {
case SORTABLE_LAYER_TYPE:
onLayerDragStart(event);
break;
case SORTABLE_EFFECT_TYPE:
onEffectDragStart(event);
break;
default:
Console.log(`activeType ${activeType} unknown`);
}
},
[onLayerDragStart, onEffectDragStart]
);
Expand Down

0 comments on commit 5c16027

Please sign in to comment.