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

452/Fix network selector on mobile #503

Merged
merged 1 commit into from
May 3, 2022

Conversation

alfetopito
Copy link
Collaborator

Summary

Closes #452

Network selector is now clickable on mobile devices

To Test

  1. On a mobile device, open the app
  2. Click on the network switcher
  • It should pop the network selector
  1. Select a different network than the current one
  • It should change the network and close the selector
  1. Repeat steps 2 and 3 for another network

@alfetopito alfetopito self-assigned this May 3, 2022
@alfetopito alfetopito requested review from a team May 3, 2022 10:04
@github-actions
Copy link
Contributor

github-actions bot commented May 3, 2022

CLA Assistant Lite All Contributors have signed the CLA.

@github-actions
Copy link
Contributor

github-actions bot commented May 3, 2022

  • 🔭 GP Swap: CoW Protocol v2 Swap UI

Copy link

@elena-zh elena-zh left a comment

Choose a reason for hiding this comment

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

Great job!

@@ -298,6 +299,10 @@ export default function NetworkSelector() {
const addPopup = useAddPopup()
const removePopup = useRemovePopup()

// mod: When on mobile, disable on hover and enable on click events
const onHoverEvent = () => !isMobile && toggle()
Copy link
Contributor

Choose a reason for hiding this comment

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

while this works it doesn't really work if u resize the window, just kinda sucks. still approving tho

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

But if you resize the window the user agent doesn't change.
If you want I could add that rule too, but doesn't work very well.
At first I tried addressing it by using the window size as reference

Copy link
Contributor

Choose a reason for hiding this comment

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

I think the issue here is, the fact that we derive isMobile from the userAgent. As @W3stside points out, this doesn't work well with resizing windows. I think the better approach is to use media query detection and align the breakpoints (e.g. upToSmall etc.) with our existing media queries.

A library such as https://www.npmjs.com/package/react-responsive solves for that and comes with a onChange function.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

But window resizing doesn't change the fact that the cursor is still a mouse and will have a 'on hover' effect.
The point here is that on mobile there is no such thing, regardless of the screen size.

Copy link
Contributor

Choose a reason for hiding this comment

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

@alfetopito Your point makes sense. I see we use a JS programmatic way of detecting the hover. E.g. with a CSS hover, on mobile the :hover is implied on click. So I get the current implementation.

That being said, I think there's value to go for mediaQuery detection vs. userAgent in general. Just in this case the only thing that I feel stands in the way here, is that we programmatically detect a HOVER event. And with mediaQueries you could technically detect a 'tablet' or 'medium' resolution which in actuality is a desktop without touch capabilities... So fine with with how it is 😅

@alfetopito alfetopito merged commit b99922c into release/1.14 May 3, 2022
@github-actions github-actions bot locked and limited conversation to collaborators May 3, 2022
@alfetopito alfetopito deleted the 452/network-selector-fix-on-mobile branch May 3, 2022 15:48
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.

4 participants