Skip to content

Commit

Permalink
Merge pull request #8 from gravity-ui/fix_block_event_propagation
Browse files Browse the repository at this point in the history
fix(Camera): fix block event propagation
  • Loading branch information
Antamansid authored Oct 10, 2024
2 parents cd8a3c7 + 0b9ca02 commit 79f3783
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/components/canvas/blocks/controllers/BlockController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,18 +33,20 @@ export class BlockController<T extends TBlock = TBlock, Props extends TBlockProp
},

mousedown(event: MouseEvent) {
event.stopPropagation();
const blockState = selectBlockById(block.context.graph, block.props.id);
const blocksListState = this.context.graph.rootStore.blocksList;
const selectedBlocksStates = getSelectedBlocks(blockState, blocksListState);
const selectedBlocksComponents = selectedBlocksStates.map((block) => block.getViewComponent());
const allowChangeBlockGeometry = isAllowChangeBlockGeometry(
block.getConfigFlag("canChangeBlockGeometry") as ECanChangeBlockGeometry,
blockState.selected
);

if (!allowChangeBlockGeometry) return;

event.stopPropagation();

const blocksListState = this.context.graph.rootStore.blocksList;
const selectedBlocksStates = getSelectedBlocks(blockState, blocksListState);
const selectedBlocksComponents = selectedBlocksStates.map((block) => block.getViewComponent());

dragListener(block.context.ownerDocument)
.on(EVENTS.DRAG_START, (_event: MouseEvent) => {
dispatchEvents(selectedBlocksComponents, createCustomDragEvent(EVENTS.DRAG_START, _event));
Expand Down

0 comments on commit 79f3783

Please sign in to comment.