Skip to content
This repository has been archived by the owner on May 7, 2021. It is now read-only.

Fix focus #1325

Merged
merged 5 commits into from
Feb 7, 2020
Merged

Fix focus #1325

merged 5 commits into from
Feb 7, 2020

Conversation

sastels
Copy link
Contributor

@sastels sastels commented Feb 7, 2020

Fixes #1142

Description

When a new screen loads, scroll to the top. Previously the focus was at the middle of the new screen.

There's more lines of code here fixing the tests than fixing the app 🤦‍♂

Checklist:

  • I have looked at my code on GitHub and it all looks good (ex: no random commented out code or console.logs)
  • I have added and needed tests for my changes (in particular for new screens)
  • I have added a comment to any confusing code

@sastels sastels temporarily deployed to rac-prototyp-fix-focus-bqgjzuz February 7, 2020 20:00 Inactive
@sastels sastels temporarily deployed to rac-prototyp-fix-focus-bqgjzuz February 7, 2020 20:01 Inactive
@sastels sastels temporarily deployed to rac-prototyp-fix-focus-bqgjzuz February 7, 2020 20:07 Inactive
@sastels sastels temporarily deployed to rac-prototyp-fix-focus-bqgjzuz February 7, 2020 20:09 Inactive
@sastels sastels temporarily deployed to rac-prototyp-fix-focus-bqgjzuz February 7, 2020 20:25 Inactive
@@ -13,19 +13,20 @@ i18n.load('en', { en })
i18n.activate('en')

describe('<BusinessPage />', () => {
afterEach(cleanup)
beforeEach(() => (global.scrollTo = jest.fn()))
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The window object that the app uses only exists when running in a browser, not when running in jest. So for the tests to use window.scrollTo(), we make the function manually by setting it to a fake jest function. And for some reason we set global.scrollTo rather than window.scrollTo 🤷‍♂

Copy link
Contributor

@naomiseminega naomiseminega left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!

@sastels sastels temporarily deployed to rac-prototyp-fix-focus-bqgjzuz February 7, 2020 21:56 Inactive
@sastels sastels merged commit ba62046 into master Feb 7, 2020
@sastels sastels deleted the fix-focus branch February 7, 2020 22:30
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Page focus is not consistently at the top of pages
2 participants