Skip to content

Commit a33a950

Browse files
committed
Merge branch 'bugfix/move-topic-url' into develop
There has been a long-standing bug in the OnTopic Editor where the URLs of topics in the tree view are broken after being moved. That's because while ExtJS moves the nodes within the tree, it doesn't make any updates to their `path` or `webPath` properties. As such, if they are clicked on, they will still go to their old location, thus yielding a 404 Not Found. This issue is compounded if the user is currently on the topic that was moved, or is a descendant of that topic. In that case, if the user performs an action such as save, it will return a 404 Not Found since it will attempt to post back to the original URL. These issues are resolved by reloading the tree view after a topic is moved. And if the topic that was moved in the current topic or an ascendant, then the user will be redirected to the new URL, thus ensuring the form and its actions are refreshed. In many cases, these never caused problems as the user would click to another page after performing a move. But for the scenarios where the above conditions were met, the behavior was unintuitive and frustrating.
2 parents 37eb773 + 0fff696 commit a33a950

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

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

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,20 @@
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+
//Otherwise, refresh the tree to ensure the new webPaths are reflected
108+
else {
109+
currentPosition = currentTopic.indexOf(':', 5);
110+
tree.getRootNode().reload();
111+
}
112+
113+
});
100114
101115
}
102116
}

0 commit comments

Comments
 (0)