-
Notifications
You must be signed in to change notification settings - Fork 78
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
base: main
Are you sure you want to change the base?
Fix mobile location tab #1106
Conversation
There was a problem hiding this 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); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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! |
There was a problem hiding this 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} |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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
Summary
useMediaQuery
focusMap
function to set the active tab based on screen sizeTest Plan
Example
Issues
Closes #1104