Skip to content
This repository has been archived by the owner on Aug 13, 2023. It is now read-only.

Move media query hooks to Simorgh #2801

Merged
merged 10 commits into from
Dec 10, 2019
Merged

Move media query hooks to Simorgh #2801

merged 10 commits into from
Dec 10, 2019

Conversation

AlistairGempf
Copy link
Contributor

Resolves #NUMBER

Overall change: Remove the media query hook so that it can be added in simorgh to allow for other actions to be triggered on a media query.

Code changes:

  • Remove media query hooks (to be added back in simorgh to allow for other parts of the nav to be controlled based on the media query)
  • Add an isScrollable prop to be set in Simorgh based on the media query hook

  • I have assigned myself to this PR and the corresponding issues
  • Automated jest tests added (for new features) or updated (for existing features)
  • This PR requires manual testing

@AlistairGempf AlistairGempf added the ws-home Tasks for the WS Home Team label Dec 9, 2019
@AlistairGempf AlistairGempf self-assigned this Dec 9, 2019
Copy link
Contributor

@Bopchy Bopchy left a comment

Choose a reason for hiding this comment

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

LGTM 👍

Comment on lines 155 to 157
mediaQueryList.addListener(event => {
setIsScrollable(event.matches);
});
Copy link
Contributor

Choose a reason for hiding this comment

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

With this refactor we don't have the removeListener method anymore.

    const handler = event => setMatches(event.matches);

    mediaQueryList.addListener(handler);
    return () => mediaQueryList.removeListener(handler);

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point, I'll add this back in for the story to prevent the storybook slowing down due to there being a load of extra listeners that aren't being used anymore.

Copy link
Contributor

@DenisHdz DenisHdz left a comment

Choose a reason for hiding this comment

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

LGTM

@AlistairGempf AlistairGempf merged commit c5b0daa into latest Dec 10, 2019
@AlistairGempf AlistairGempf deleted the isScrollable-prop branch December 10, 2019 10:02
@BBC-archive BBC-archive deleted a comment from AlistairGempf Dec 16, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
ws-home Tasks for the WS Home Team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants