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 mobile location tab #1106

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

Fix mobile location tab #1106

wants to merge 2 commits into from

Conversation

vinnyho
Copy link
Contributor

@vinnyho vinnyho commented Jan 12, 2025

Summary

  • Implemented mobile screen check using useMediaQuery
  • Updated focusMap function to set the active tab based on screen size

Test Plan

  • Tested functionality on mobile screen
  • Ensured functionality on desktop screen

Example

Animation

Issues

Closes #1104

Copy link
Member

@MinhxNguyen7 MinhxNguyen7 left a comment

Choose a reason for hiding this comment

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

I know this is scope creep, but seeing that his change had to be performed in two places reminded me that the link/button itself should be extracted to its own component (e.g., MapLink) in components/buttons. Would you mind doing that?

Also, it seems a little janky to set the tab index depending on a media query, but it's not obvious to be what would be a better way other than to completely refactor the tab store to use keys instead of indices, which is completely out of scope here.


const focusMap = useCallback(() => {
setActiveTab(2);
setActiveTab(isMobileScreen ? 3 : 2);
Copy link
Member

Choose a reason for hiding this comment

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

I believe you need to add the isMobileScreen to the useCallback's dependency array to allow this fix to work when the screen is resized.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think in putting the isMobileScreen to the useCallback's dependency array causes the whole page to want to refresh for some reason, while putting it before doesn't.

@vinnyho
Copy link
Contributor Author

vinnyho commented Jan 14, 2025

Please let me know if there are any changes that needs to be made, it worked well on my end with the new component on both mobile and desktop. Thank you!

Copy link
Member

@MinhxNguyen7 MinhxNguyen7 left a comment

Choose a reason for hiding this comment

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

Just a few little things

<MapLink
buildingId={buildingId}
buildingName={bldg}
focusMap={focusMap}
Copy link
Member

Choose a reason for hiding this comment

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

The point to the MapLink is to move the map-focusing business logic into there so that we don't have to keep re-writing the focusMap component.


interface MapLinkProps {
buildingId: number;
buildingName: string;
Copy link
Member

Choose a reason for hiding this comment

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

This is a misnomer, since it has both the building and the room number

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Mobile map-linking opens added tab instead of map
2 participants