From d529c98983d8aa774252050d9a0b8e8a3c392245 Mon Sep 17 00:00:00 2001 From: Tom Moor Date: Sat, 23 Jun 2018 18:11:01 -0700 Subject: [PATCH] Fixes #697 --- app/components/ScrollToTop.js | 13 ++++++++++--- package.json | 2 +- yarn.lock | 6 +++--- 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/app/components/ScrollToTop.js b/app/components/ScrollToTop.js index 490b432c9..a877045bf 100644 --- a/app/components/ScrollToTop.js +++ b/app/components/ScrollToTop.js @@ -5,9 +5,16 @@ import { withRouter } from 'react-router-dom'; class ScrollToTop extends React.Component<*> { componentDidUpdate(prevProps) { - if (this.props.location !== prevProps.location) { - window.scrollTo(0, 0); - } + if (this.props.location.pathname === prevProps.location.pathname) return; + + // exception for when entering or exiting document edit, scroll postion should not reset + if ( + this.props.location.pathname.match(/\/edit\/?$/) || + prevProps.location.pathname.match(/\/edit\/?$/) + ) + return; + + window.scrollTo(0, 0); } render() { diff --git a/package.json b/package.json index ed911ca5e..cdd7cb683 100644 --- a/package.json +++ b/package.json @@ -158,7 +158,7 @@ "react-waypoint": "^7.3.1", "redis": "^2.6.2", "redis-lock": "^0.1.0", - "rich-markdown-editor": "1.4.0-2", + "rich-markdown-editor": "1.4.1", "safestart": "1.1.0", "sequelize": "4.28.6", "sequelize-cli": "^2.7.0", diff --git a/yarn.lock b/yarn.lock index 3fd57ba58..0150c9e86 100644 --- a/yarn.lock +++ b/yarn.lock @@ -8859,9 +8859,9 @@ retry-axios@0.3.2, retry-axios@^0.3.2: version "0.3.2" resolved "https://registry.yarnpkg.com/retry-axios/-/retry-axios-0.3.2.tgz#5757c80f585b4cc4c4986aa2ffd47a60c6d35e13" -rich-markdown-editor@1.4.0-2: - version "1.4.0-2" - resolved "https://registry.yarnpkg.com/rich-markdown-editor/-/rich-markdown-editor-1.4.0-2.tgz#5d8795cef27e0c48ba5689be43dd02a1a0c02368" +rich-markdown-editor@1.4.1: + version "1.4.1" + resolved "https://registry.yarnpkg.com/rich-markdown-editor/-/rich-markdown-editor-1.4.1.tgz#c339e216009e44a17427843f80847f8cfcb815c7" dependencies: "@tommoor/slate-drop-or-paste-images" "^0.8.1" boundless-arrow-key-navigation "^1.1.0"