Commit 31feced2 authored by James O'Dwyer's avatar James O'Dwyer Committed by Naoyuki Kanezawa

Avoid autoscrolling anchored URLs (#474)

* force scroll to false if # is found in url

* only overwrite scroll if scroll=true is not passed in

* clean up logic around setting scroll var
parent eb9a61e9
...@@ -14,7 +14,7 @@ export default class Link extends Component { ...@@ -14,7 +14,7 @@ export default class Link extends Component {
return return
} }
const { href, scroll, as } = this.props const { href, as } = this.props
if (!isLocal(href)) { if (!isLocal(href)) {
// ignore click if it's outside our scope // ignore click if it's outside our scope
...@@ -26,6 +26,12 @@ export default class Link extends Component { ...@@ -26,6 +26,12 @@ export default class Link extends Component {
const route = as ? href : null const route = as ? href : null
const url = as || href const url = as || href
// avoid scroll for urls with anchor refs
let { scroll } = this.props
if (scroll == null) {
scroll = url.indexOf('#') < 0
}
// straight up redirect // straight up redirect
Router.push(route, url) Router.push(route, url)
.then((success) => { .then((success) => {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment