From b9451bef4a92dc87c9d6ca65b70410743a6a818a Mon Sep 17 00:00:00 2001 From: Shyam Sunder Date: Fri, 8 Jan 2021 10:21:56 -0500 Subject: [PATCH] client/posts/edit: maintain post editing state for arrow key nav Fixes #373 --- client/js/views/post_main_view.js | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/client/js/views/post_main_view.js b/client/js/views/post_main_view.js index 73bb324..c38a933 100644 --- a/client/js/views/post_main_view.js +++ b/client/js/views/post_main_view.js @@ -61,13 +61,29 @@ class PostMainView { const showPreviousImage = () => { if (ctx.prevPostId) { - router.show(ctx.getPostUrl(ctx.prevPostId, ctx.parameters)); + if (ctx.editMode) { + router.show( + ctx.getPostEditUrl(ctx.prevPostId, ctx.parameters) + ); + } else { + router.show( + ctx.getPostUrl(ctx.prevPostId, ctx.parameters) + ); + } } }; const showNextImage = () => { if (ctx.nextPostId) { - router.show(ctx.getPostUrl(ctx.nextPostId, ctx.parameters)); + if (ctx.editMode) { + router.show( + ctx.getPostEditUrl(ctx.nextPostId, ctx.parameters) + ); + } else { + router.show( + ctx.getPostUrl(ctx.nextPostId, ctx.parameters) + ); + } } };