https://github.com/outline/outline/blob/master/app/scenes/UserDelete.js#L40: corrected "destory" to "destroy" https://github.com/outline/outline/blob/master/app/components/ScrollToTop.js#L16: corrected "postion" to "position" https://github.com/outline/outline/blob/master/server/policies/document.js#L11: corrected "existance" to "existence" https://github.com/outline/outline/blob/master/server/policies/document.js#L23: corrected "existance" to "existence" https://github.com/outline/outline/blob/master/server/models/Document.js#L493: corrected "permanantly" to "permanently" https://github.com/outline/outline/blob/master/shared/utils/domains.js#L12: corrected "unneccessarily" to "unnecessarily" https://github.com/outline/outline/blob/master/server/api/documents.js#L34: corrected "compatablity" to "compatibility"
32 lines
810 B
JavaScript
32 lines
810 B
JavaScript
// @flow
|
|
// based on: https://reacttraining.com/react-router/web/guides/scroll-restoration
|
|
import * as React from "react";
|
|
import { withRouter } from "react-router-dom";
|
|
import type { Location } from "react-router-dom";
|
|
|
|
type Props = {
|
|
location: Location,
|
|
children: React.Node,
|
|
};
|
|
|
|
class ScrollToTop extends React.Component<Props> {
|
|
componentDidUpdate(prevProps) {
|
|
if (this.props.location.pathname === prevProps.location.pathname) return;
|
|
|
|
// exception for when entering or exiting document edit, scroll position should not reset
|
|
if (
|
|
this.props.location.pathname.match(/\/edit\/?$/) ||
|
|
prevProps.location.pathname.match(/\/edit\/?$/)
|
|
)
|
|
return;
|
|
|
|
window.scrollTo(0, 0);
|
|
}
|
|
|
|
render() {
|
|
return this.props.children;
|
|
}
|
|
}
|
|
|
|
export default withRouter(ScrollToTop);
|