From 8af7c3c264eec89afe05a1c0d935e3c38f2588b5 Mon Sep 17 00:00:00 2001 From: Tom Moor Date: Sun, 17 Feb 2019 00:38:35 -0800 Subject: [PATCH] Closes #894 - Sidebar jumping regression --- app/components/DropToImport.js | 5 +++++ app/routes.js | 17 +++++++---------- app/scenes/Document/Document.js | 1 - app/scenes/Document/KeyedDocument.js | 16 ++++++++++++++++ 4 files changed, 28 insertions(+), 11 deletions(-) create mode 100644 app/scenes/Document/KeyedDocument.js diff --git a/app/components/DropToImport.js b/app/components/DropToImport.js index e43eb1db..68e53f30 100644 --- a/app/components/DropToImport.js +++ b/app/components/DropToImport.js @@ -20,6 +20,8 @@ type Props = { rejectClassName?: string, documents: DocumentsStore, disabled: boolean, + location: Object, + match: Object, history: Object, }; @@ -76,6 +78,9 @@ class DropToImport extends React.Component { collectionId, documents, disabled, + location, + match, + history, ...rest } = this.props; diff --git a/app/routes.js b/app/routes.js index 6beb6bfa..6c9002eb 100644 --- a/app/routes.js +++ b/app/routes.js @@ -1,13 +1,13 @@ // @flow import * as React from 'react'; import { Switch, Route, Redirect } from 'react-router-dom'; - import Home from 'scenes/Home'; import Dashboard from 'scenes/Dashboard'; import Starred from 'scenes/Starred'; import Drafts from 'scenes/Drafts'; import Collection from 'scenes/Collection'; import Document from 'scenes/Document'; +import KeyedDocument from 'scenes/Document/KeyedDocument'; import Search from 'scenes/Search'; import Settings from 'scenes/Settings'; import Details from 'scenes/Settings/Details'; @@ -27,19 +27,16 @@ import RouteSidebarHidden from 'components/RouteSidebarHidden'; import { matchDocumentSlug as slug } from 'utils/routeHelpers'; const NotFound = () => ; -const DocumentNew = () => ; +const NewDocument = () => ; const RedirectDocument = ({ match }: { match: Object }) => ( ); -const RemountDocument = props => ( - -); export default function Routes() { return ( - + @@ -74,7 +71,7 @@ export default function Routes() { @@ -82,14 +79,14 @@ export default function Routes() { - + diff --git a/app/scenes/Document/Document.js b/app/scenes/Document/Document.js index 534ff0c6..3c829988 100644 --- a/app/scenes/Document/Document.js +++ b/app/scenes/Document/Document.js @@ -89,7 +89,6 @@ class DocumentScene extends React.Component { componentWillUnmount() { clearTimeout(this.viewTimeout); - this.props.ui.clearActiveDocument(); } goToDocumentCanonical = () => { diff --git a/app/scenes/Document/KeyedDocument.js b/app/scenes/Document/KeyedDocument.js new file mode 100644 index 00000000..72dd69d9 --- /dev/null +++ b/app/scenes/Document/KeyedDocument.js @@ -0,0 +1,16 @@ +// @flow +import * as React from 'react'; +import { inject } from 'mobx-react'; +import Document from '.'; + +class KeyedDocument extends React.Component<*> { + componentWillUnmount() { + this.props.ui.clearActiveDocument(); + } + + render() { + return ; + } +} + +export default inject('ui')(KeyedDocument);