Skip to content

Commit

Permalink
Fix nodes getting unselected after drag
Browse files Browse the repository at this point in the history
- [Part of comment](#166 (review))
  • Loading branch information
quirinpa committed Jul 24, 2023
1 parent 01ac748 commit 84cecbc
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 11 deletions.
6 changes: 0 additions & 6 deletions src/editors/Flow/view/Components/interface/MainInterface.js
Original file line number Diff line number Diff line change
Expand Up @@ -422,8 +422,6 @@ export default class MainInterface {
* @returns {MainInterface} : The instance
*/
addSubscribers = () => {
this.mode.default.onEnter.subscribe(this.onDefault);

// drag mode -> onExit event
this.mode.drag.onExit.subscribe(this.onDragEnd);

Expand Down Expand Up @@ -464,10 +462,6 @@ export default class MainInterface {
* */
//========================================================================================

onDefault = () => {
this.selectedNodes = [];
};

onDragEnd = draggedNode => {
const selectedNodesSet = new Set([draggedNode].concat(this._selectedNodes));
const nodes = Array.from(selectedNodesSet).filter(obj => obj);
Expand Down
8 changes: 7 additions & 1 deletion src/editors/Flow/view/Components/interface/canvas.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { Subject } from "rxjs";
import FlowModel from "../../../model/Flow";
import { defaultFunction } from "../../../../../utils/Utils";
import Factory from "../../Components/Nodes/Factory";
import { PLUGINS } from "../../../../../utils/Constants";
import {
FLOW_VIEW_MODE,
CANVAS_LIMITS,
Expand Down Expand Up @@ -522,8 +523,13 @@ class Canvas {
if (this.mode.current.onClick)
this.mode.current.onClick.next();
else {
this.setMode(EVT_NAMES.DEFAULT, null, true);
this.mInterface.selectedNodes = [];
this.mInterface.docManager(
PLUGINS.RIGHT_DRAWER.NAME,
PLUGINS.RIGHT_DRAWER.CALL.REMOVE_BOOKMARK,
"node-menu",
"detail-menu"
);
}
};

Expand Down
2 changes: 0 additions & 2 deletions src/editors/Flow/view/Core/Graph/GraphBase.js
Original file line number Diff line number Diff line change
Expand Up @@ -626,8 +626,6 @@ export default class GraphBase {
};

reset() {
// Reset all selected nodes
this.mInterface.selectedNodes = [];
// Reset selected link
if (this.selectedLink) {
this.selectedLink.onSelected(false);
Expand Down
3 changes: 1 addition & 2 deletions src/editors/Flow/view/Flow.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -756,7 +756,6 @@ export const Flow = (props, ref) => {
const setFlowsToDefault = useCallback(() => {
activateEditor();
// Remove selected node and link bookmark
onNodeSelected(null);
onLinkSelected(null);
// Update render of right menu
// broadcast event to other flows
Expand All @@ -766,7 +765,7 @@ export const Flow = (props, ref) => {
PLUGINS.DOC_MANAGER.ON.FLOW_EDITOR,
{ action: "setMode", value: EVT_NAMES.DEFAULT }
);
}, [call, onLinkSelected, onNodeSelected]);
}, [call, onLinkSelected]);

/**
* Subscribe to mainInterface and canvas events
Expand Down

0 comments on commit 84cecbc

Please sign in to comment.