Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reset focus when scrolling to top of page? #117

Open
silouanwright opened this issue Mar 9, 2017 · 1 comment
Open

Reset focus when scrolling to top of page? #117

silouanwright opened this issue Mar 9, 2017 · 1 comment

Comments

@silouanwright
Copy link

silouanwright commented Mar 9, 2017

So because the page is scrolling to the top (and emulating a new page render), would it make sense to reset the focus to the top of the page?

The kicker here is that I could attempt to do this myself, but here's some sample code:

const history = withScroll(createHistory(), (prevLocation, location) => {
    // scroll to top when visiting a new page
    // except for month section on the calendar page
    const prevPath = prevLocation ? prevLocation.pathname : null;
    const path = location.pathname;
    return !prevPath
    || !(prevPath.includes('/random-page/') && path.includes('/random-page/'))
        ? [0, 0] : false;
});

Basically this is just the scroll logic, but in some instances we don't want to scroll to the top. So it would make sense for this piece of functionality to be bundled with withScroll as some sort of boolean we would pass. Thoughts?

(side note: I am using this version, and I'll eventually want to use the react specific version of this package, but this is what I'm using now)

@taion
Copy link
Owner

taion commented Mar 9, 2017

Seems reasonable. Care to send a PR?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants