Skip to content

Commit

Permalink
#1691 Link temporarily visually connected to new target when cancelli…
Browse files Browse the repository at this point in the history
…ng updateLink via beforeEditActionHandler (#1692)
  • Loading branch information
tomlyn authored Feb 12, 2024
1 parent e2177cd commit 6fbdee3
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2168,6 +2168,11 @@ export default class CanvasController {
}
}

// Performs edit actions, based on the cmndData passed in, to the object
// model which result in changes to the displayed canvas. Returns true if
// the action completes successfully and false if it does not complete,
// for example, if the host application cancels the action by returning
// false from the beforeEditActionHanlder.
editActionHandler(cmndData) {
this.logger.log("editActionHandler - " + cmndData.editType);
this.logger.log(cmndData);
Expand Down Expand Up @@ -2203,17 +2208,17 @@ export default class CanvasController {
data = this.handlers.beforeEditActionHandler(data, cmnd);
// If the host app returns null, it doesn't want the action to proceed.
if (!data) {
return;
return false;
}
// If an external pipeline flow was requested, we need to make sure it
// was provided by the host app. We can't proceed if it was not.
if (!this.wasExtPipelineFlowLoadSuccessful(data)) {
return;
return false;
}
}

// Now preprocessing is complete, execuete the action itself.
this.editAction(data);
return this.editAction(data);
}

// Performs the edit action using the 'data' parameter, which contains the
Expand All @@ -2232,7 +2237,7 @@ export default class CanvasController {
// 'delete' is pressed on the keyboard.
if (data.editType === "deleteSelectedObjects" &&
data.selectedObjectIds.length === 0) {
return;
return false;
}

// These commands are supported for the external AND internal object models.
Expand Down Expand Up @@ -2561,6 +2566,8 @@ export default class CanvasController {
// pipeline visible they will be loaded one by one when this check is
// encountered.
this.ensureVisibleExpandedPipelinesAreLoaded();

return true;
}

// Sets the appropriate values when handling an external pipleine flow
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,12 +168,19 @@ export default class SVGCanvasUtilsDragDetLink {
// If editSubType is set the user did a gesture that requires a change
// to the object model.
if (editSubType) {
this.ren.canvasController.editActionHandler({
const success = this.ren.canvasController.editActionHandler({
editType: "updateLink",
editSubType: editSubType,
editSource: "canvas",
newLink: newLink,
pipelineId: this.ren.activePipeline.id });

// The call to editActionHandler might "fail" if the host app
// uses beforeEditActionHandler to cancel the edit action. In
// this case, we snap the link back to its old position.
if (!success) {
this.snapBackOldLink(draggingLinkData.oldLink);
}
// If editSubType is null, the user performed a gesture which should
// not be executed as an action so draw the link back in its old position.
} else {
Expand Down

0 comments on commit 6fbdee3

Please sign in to comment.