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

fix(select): Fix undesired scrolling when activating menu #795

Merged
merged 2 commits into from
Jul 23, 2020

Conversation

jamesfan
Copy link
Member

Summary

Fixes an issue where activating the Labs Select menu caused the browser to scroll to the top of the page.

In #535, we modified Select to focus the menu inside of a useLayoutEffect call with an empty dependency array (previously, focus was being applied to the menu using Popper's onFirstUpdate). This had the unintended consequence of causing the browser to scroll to the top of the page whenever a Select menu was activated -- we suspect focus was being applied after the menu had been rendered but before it had been positioned by Popper, thus causing the browser to scroll to the top of the page where the menu is originally positioned prior to being moved by Popper.

As an immediate fix, I've reverted to the previous method of focusing the menu using onFirstUpdate. The long-term solution to this issue (and other similar timing issues) may involve creating a programmatic focus function to handle these issues in a more centralized fashion.

I've also added a Cypress test to protect against this regression in the future.

@jamesfan jamesfan added bug Something isn't working ready for review Code is ready for review labels Jul 23, 2020
@jamesfan jamesfan self-assigned this Jul 23, 2020
@project-bot project-bot bot added this to Needs Review in Current Sprint (7/20 - 8/9) Jul 23, 2020
Current Sprint (7/20 - 8/9) automation moved this from Needs Review to In Progress Jul 23, 2020
@jamesfan jamesfan moved this from In Progress to Needs Review in Current Sprint (7/20 - 8/9) Jul 23, 2020
@cypress
Copy link

cypress bot commented Jul 23, 2020



Test summary

430 0 1 0


Run details

Project canvas-kit
Status Passed
Commit e8ba032 ℹ️
Started Jul 23, 2020 8:22 AM
Ended Jul 23, 2020 8:26 AM
Duration 04:28 💡
OS Linux Ubuntu Linux - 18.04
Browser Electron 80

View run in Cypress Dashboard ➡️


This comment has been generated by cypress-bot as a result of this project's GitHub integration settings. You can manage this integration in this project's settings in the Cypress Dashboard

@NicholasBoll NicholasBoll merged commit 9f9a4f6 into Workday:master Jul 23, 2020
Current Sprint (7/20 - 8/9) automation moved this from Needs Review to Done Jul 23, 2020
@jamesfan jamesfan deleted the fix-select-focus-scrolling branch August 6, 2020 22:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working ready for review Code is ready for review
Projects
No open projects
Development

Successfully merging this pull request may close these issues.

None yet

2 participants