Skip to content
5 changes: 5 additions & 0 deletions core/dragging/block_drag_strategy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {ConnectionType} from '../connection_type.js';
import type {BlockMove} from '../events/events_block_move.js';
import {EventType} from '../events/type.js';
import * as eventUtils from '../events/utils.js';
import {getFocusManager} from '../focus_manager.js';
import {IConnectionPreviewer} from '../interfaces/i_connection_previewer.js';
import {IDragStrategy} from '../interfaces/i_draggable.js';
import * as layers from '../layers.js';
Expand Down Expand Up @@ -120,6 +121,10 @@ export class BlockDragStrategy implements IDragStrategy {
}
this.block.setDragging(true);
this.workspace.getLayerManager()?.moveToDragLayer(this.block);

// Since moving the block to the drag layer will cause it to lose focus,
// ensure it regains focus (to enable the block's selection highlight).
getFocusManager().focusNode(this.block);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Question: should this be done in moveToDragLayer (and moveOffDragLayer) instead of in the drag strategy?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea. This actually made me realize that workspace comments had the same problem, so this shift actually fixes those, too.

}

/**
Expand Down