Skip to content

Commit e6a33fa

Browse files
committed
Perform redirect onmovenode()
When the current topic—or any of its ascendents—is moved in the `TreePanel`, the current page's URL will no longer be valid. As a result, if the editor then performs an action on that page, such as saving a change, it will fail since it will attempt to post back to the original URL. To mitigate this, we now perform a redirect in `movenode()` if the `node` is the `currentTopic` or an ascendent of it. This will put the user on the same topic, but in its new location.
1 parent 37eb773 commit e6a33fa

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

OnTopic.Editor.AspNetCore/Areas/Editor/Views/Shared/_TreeViewScript.cshtml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,14 @@
9797
url: "/OnTopic/Move",
9898
data: { topicId: node.attributes.id, targetTopicId: newParent.attributes.id, siblingId }
9999
})
100+
.done(function() {
101+
102+
//If current or ascendent topic, redirect to new location since the current URL is no longer valid
103+
if (currentTopic.startsWith(node.attributes.path)) {
104+
location.href = location.href.replace(oldParent.attributes.webPath, newParent.attributes.webPath);
105+
}
106+
107+
});
100108
101109
}
102110
}

0 commit comments

Comments
 (0)