diff --git a/docs/scss/docs/Layout.scss b/docs/scss/docs/Layout.scss index 28c415eb238..0cef521474c 100644 --- a/docs/scss/docs/Layout.scss +++ b/docs/scss/docs/Layout.scss @@ -3,14 +3,14 @@ $sidebar-width: 250px; .Layout { background-color: $gray; - &-container, &-navigationContainer, &-content { - height: 100%; + min-height: 100%; } &-container { - padding-top: $nav-height; + min-height: calc(100% - #{$nav-height}); + margin-top: $nav-height; } &-navigationContainer { diff --git a/docs/scss/layout.scss b/docs/scss/layout.scss index bde11bd010b..a5875693f64 100644 --- a/docs/scss/layout.scss +++ b/docs/scss/layout.scss @@ -2,5 +2,5 @@ html, body, #root, [data-reactroot] { - height: 100%; + min-height: 100%; } diff --git a/docs/src/App.js b/docs/src/App.js index b4a934d98ff..7bc5f4e3a6f 100644 --- a/docs/src/App.js +++ b/docs/src/App.js @@ -29,11 +29,35 @@ function logPageView() { ReactGA.pageview(window.location.pathname); } +// https://github.com/ReactTraining/react-router/issues/394#issuecomment-220221604 +function hashLinkScroll() { + const { hash } = window.location; + if (hash !== '') { + // Push onto callback queue so it runs after the DOM is updated, + // this is required when navigating from a different page so that + // the element is rendered on the page before trying to getElementById. + setTimeout(() => { + const id = hash.replace('#', ''); + const element = document.getElementById(id); + if (element) { + element.scrollTop = element.offsetHeight; + } + }, 0); + } +} + +function onRouterUpdate() { + logPageView(); + hashLinkScroll(); +} + export function init() { + hashLinkScroll(); + render( diff --git a/docs/src/components/Endpoint.js b/docs/src/components/Endpoint.js index 00134855fa6..b1ed0d7465d 100644 --- a/docs/src/components/Endpoint.js +++ b/docs/src/components/Endpoint.js @@ -29,7 +29,7 @@ export default function Endpoint(props) { {methods.map(function(method, index) { return (
  • - {method.name} + {method.name}
  • ); })} diff --git a/docs/src/components/Method.js b/docs/src/components/Method.js index 6453ee5b879..ef7a8a6687f 100644 --- a/docs/src/components/Method.js +++ b/docs/src/components/Method.js @@ -78,7 +78,7 @@ export default function Method(props) { } return ( -
    +

    {name}

    {description}