From 732d0ad0300126dca929f00e975dd4c10d97e259 Mon Sep 17 00:00:00 2001 From: Robin Ward Date: Tue, 27 Dec 2016 10:52:37 -0500 Subject: [PATCH] FIX: Find the closest post to jump to if deleted --- .../javascripts/discourse/controllers/topic.js.es6 | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/app/assets/javascripts/discourse/controllers/topic.js.es6 b/app/assets/javascripts/discourse/controllers/topic.js.es6 index bc42e729259..ef4dfad0b63 100644 --- a/app/assets/javascripts/discourse/controllers/topic.js.es6 +++ b/app/assets/javascripts/discourse/controllers/topic.js.es6 @@ -454,7 +454,15 @@ export default Ember.Controller.extend(SelectedPostsCount, BufferedContent, { }, jumpToPost(postNumber) { - this._jumpToPostId(this.get('model.postStream').findPostIdForPostNumber(postNumber)); + const postStream = this.get('model.postStream'); + let postId = postStream.findPostIdForPostNumber(postNumber); + + // If we couldn't find the post, find the closest post to it + if (!postId) { + const closest = postStream.closestPostNumberFor(postNumber); + postId = postStream.findPostIdForPostNumber(closest); + } + this._jumpToPostId(postId); }, jumpTop() {