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

scrollMenuIntoView option broken on IE #799

Closed
mdocode opened this issue Feb 26, 2016 · 0 comments · Fixed by #840
Closed

scrollMenuIntoView option broken on IE #799

mdocode opened this issue Feb 26, 2016 · 0 comments · Fixed by #840

Comments

@mdocode
Copy link

mdocode commented Feb 26, 2016

in IE, when you open the select, instead of scrolling to the menu it scrolls to the top of the page. This is because the window.scrollY property doesn't exist in ie.

This is fixed by changing

if (window.innerHeight < menuContainerRect.bottom + this.props.menuBuffer) {
    window.scrollTo(0, window.scrollY + menuContainerRect.bottom + this.props.menuBuffer - window.innerHeight);
}

to

if (window.innerHeight < menuContainerRect.bottom + this.props.menuBuffer) {
    var scrollY = window.pageYOffset || document.documentElement.scrollTop
    window.scrollTo(0, scrollY + menuContainerRect.bottom + this.props.menuBuffer - window.innerHeight);
}

as in remix-run/react-router#605

aij added a commit to aij/react-select that referenced this issue Mar 17, 2016
Switching to relative scrolling avoids two problems:
 1. IE does not support window.scrollY
 2. window.scrollTo(0, ...) scrolls to the left

This fixes JedWatson#799.
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

Successfully merging a pull request may close this issue.

1 participant