Closes #894 - Sidebar jumping regression
This commit is contained in:
@ -20,6 +20,8 @@ type Props = {
|
|||||||
rejectClassName?: string,
|
rejectClassName?: string,
|
||||||
documents: DocumentsStore,
|
documents: DocumentsStore,
|
||||||
disabled: boolean,
|
disabled: boolean,
|
||||||
|
location: Object,
|
||||||
|
match: Object,
|
||||||
history: Object,
|
history: Object,
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -76,6 +78,9 @@ class DropToImport extends React.Component<Props> {
|
|||||||
collectionId,
|
collectionId,
|
||||||
documents,
|
documents,
|
||||||
disabled,
|
disabled,
|
||||||
|
location,
|
||||||
|
match,
|
||||||
|
history,
|
||||||
...rest
|
...rest
|
||||||
} = this.props;
|
} = this.props;
|
||||||
|
|
||||||
|
@ -1,13 +1,13 @@
|
|||||||
// @flow
|
// @flow
|
||||||
import * as React from 'react';
|
import * as React from 'react';
|
||||||
import { Switch, Route, Redirect } from 'react-router-dom';
|
import { Switch, Route, Redirect } from 'react-router-dom';
|
||||||
|
|
||||||
import Home from 'scenes/Home';
|
import Home from 'scenes/Home';
|
||||||
import Dashboard from 'scenes/Dashboard';
|
import Dashboard from 'scenes/Dashboard';
|
||||||
import Starred from 'scenes/Starred';
|
import Starred from 'scenes/Starred';
|
||||||
import Drafts from 'scenes/Drafts';
|
import Drafts from 'scenes/Drafts';
|
||||||
import Collection from 'scenes/Collection';
|
import Collection from 'scenes/Collection';
|
||||||
import Document from 'scenes/Document';
|
import Document from 'scenes/Document';
|
||||||
|
import KeyedDocument from 'scenes/Document/KeyedDocument';
|
||||||
import Search from 'scenes/Search';
|
import Search from 'scenes/Search';
|
||||||
import Settings from 'scenes/Settings';
|
import Settings from 'scenes/Settings';
|
||||||
import Details from 'scenes/Settings/Details';
|
import Details from 'scenes/Settings/Details';
|
||||||
@ -27,19 +27,16 @@ import RouteSidebarHidden from 'components/RouteSidebarHidden';
|
|||||||
import { matchDocumentSlug as slug } from 'utils/routeHelpers';
|
import { matchDocumentSlug as slug } from 'utils/routeHelpers';
|
||||||
|
|
||||||
const NotFound = () => <Search notFound />;
|
const NotFound = () => <Search notFound />;
|
||||||
const DocumentNew = () => <Document newDocument />;
|
const NewDocument = () => <Document newDocument />;
|
||||||
const RedirectDocument = ({ match }: { match: Object }) => (
|
const RedirectDocument = ({ match }: { match: Object }) => (
|
||||||
<Redirect to={`/doc/${match.params.documentSlug}`} />
|
<Redirect to={`/doc/${match.params.documentSlug}`} />
|
||||||
);
|
);
|
||||||
const RemountDocument = props => (
|
|
||||||
<Document key={props.location.pathname} {...props} />
|
|
||||||
);
|
|
||||||
|
|
||||||
export default function Routes() {
|
export default function Routes() {
|
||||||
return (
|
return (
|
||||||
<Switch>
|
<Switch>
|
||||||
<Route exact path="/" component={Home} />
|
<Route exact path="/" component={Home} />
|
||||||
<Route exact path="/share/:shareId" component={RemountDocument} />
|
<Route exact path="/share/:shareId" component={KeyedDocument} />
|
||||||
<Authenticated>
|
<Authenticated>
|
||||||
<Layout>
|
<Layout>
|
||||||
<Switch>
|
<Switch>
|
||||||
@ -74,7 +71,7 @@ export default function Routes() {
|
|||||||
<RouteSidebarHidden
|
<RouteSidebarHidden
|
||||||
exact
|
exact
|
||||||
path="/collections/:id/new"
|
path="/collections/:id/new"
|
||||||
component={DocumentNew}
|
component={NewDocument}
|
||||||
/>
|
/>
|
||||||
<Route exact path="/collections/:id/:tab" component={Collection} />
|
<Route exact path="/collections/:id/:tab" component={Collection} />
|
||||||
<Route exact path="/collections/:id" component={Collection} />
|
<Route exact path="/collections/:id" component={Collection} />
|
||||||
@ -82,14 +79,14 @@ export default function Routes() {
|
|||||||
<Route
|
<Route
|
||||||
exact
|
exact
|
||||||
path={`/doc/${slug}/history/:revisionId?`}
|
path={`/doc/${slug}/history/:revisionId?`}
|
||||||
component={RemountDocument}
|
component={KeyedDocument}
|
||||||
/>
|
/>
|
||||||
<RouteSidebarHidden
|
<RouteSidebarHidden
|
||||||
exact
|
exact
|
||||||
path={`/doc/${slug}/edit`}
|
path={`/doc/${slug}/edit`}
|
||||||
component={RemountDocument}
|
component={KeyedDocument}
|
||||||
/>
|
/>
|
||||||
<Route path={`/doc/${slug}`} component={RemountDocument} />
|
<Route path={`/doc/${slug}`} component={KeyedDocument} />
|
||||||
<Route exact path="/search" component={Search} />
|
<Route exact path="/search" component={Search} />
|
||||||
<Route exact path="/search/:query" component={Search} />
|
<Route exact path="/search/:query" component={Search} />
|
||||||
<Route path="/404" component={Error404} />
|
<Route path="/404" component={Error404} />
|
||||||
|
@ -89,7 +89,6 @@ class DocumentScene extends React.Component<Props> {
|
|||||||
|
|
||||||
componentWillUnmount() {
|
componentWillUnmount() {
|
||||||
clearTimeout(this.viewTimeout);
|
clearTimeout(this.viewTimeout);
|
||||||
this.props.ui.clearActiveDocument();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
goToDocumentCanonical = () => {
|
goToDocumentCanonical = () => {
|
||||||
|
16
app/scenes/Document/KeyedDocument.js
Normal file
16
app/scenes/Document/KeyedDocument.js
Normal file
@ -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 <Document key={this.props.location.pathname} {...this.props} />;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default inject('ui')(KeyedDocument);
|
Reference in New Issue
Block a user