-
-
Notifications
You must be signed in to change notification settings - Fork 7
Fix: Use correct initial zoom for mobile devices #239
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
Conversation
The map component was not using the calculated `initialZoom` for mobile devices, causing the map to be zoomed in by default. This commit fixes the issue by: - Updating `currentMapCenterRef.current.zoom` with the `initialZoom` value. - Using `initialZoom` when creating the `mapboxgl.Map` instance. This ensures that mobile and tablet devices get the appropriate zoom level for a full globe preview.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
WalkthroughThe Mapbox map initialization now sets currentMapCenterRef.current.zoom to the computed initialZoom before creating the map and passes zoom: initialZoom into the Map constructor. No other exported entities or control flow were changed. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
participant UI as UI
participant MapComp as Map Component
participant Mapbox as Mapbox GL
UI->>MapComp: Mount component
MapComp->>MapComp: Compute initialZoom (viewport-based)
Note over MapComp: Update ref: currentMapCenterRef.current.zoom = initialZoom
MapComp->>Mapbox: new Map({ center, zoom: initialZoom, ... })
Mapbox-->>MapComp: Map instance ready
MapComp-->>UI: Render map with aligned initial zoom
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~2 minutes Suggested labels
Poem
Tip 🔌 Remote MCP (Model Context Protocol) integration is now available!Pro plan users can now connect to remote MCP servers from the Integrations page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats. ✨ Finishing Touches
🧪 Generate unit tests
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR/Issue comments)Type Other keywords and placeholders
CodeRabbit Configuration File (
|
|
|
PR Reviewer Guide 🔍Here are some key observations to aid the review process:
|
PR Reviewer Guide 🔍Here are some key observations to aid the review process:
|
PR Code Suggestions ✨Explore these optional code suggestions:
|
|||||||||
PR Code Suggestions ✨Explore these optional code suggestions:
|
||||||||||||
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.
Actionable comments posted: 0
🧹 Nitpick comments (1)
components/map/mapbox-map.tsx (1)
398-404: Nit: Use the ref as the single source of truth when constructing the Map.You’ve just synced the ref to
initialZoom; using the ref in the constructor keeps the configuration tied to that source of truth and avoids accidental drift if the initialization logic evolves.Apply this minimal diff:
- zoom: initialZoom, + zoom: currentMapCenterRef.current.zoom,
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
💡 Knowledge Base configuration:
- MCP integration is disabled by default for public repositories
- Jira integration is disabled by default for public repositories
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (1)
components/map/mapbox-map.tsx(1 hunks)
🔇 Additional comments (1)
components/map/mapbox-map.tsx (1)
398-404: Initial zoom now applied consistently to Map and ref — aligns with PR goal.Setting
currentMapCenterRef.current.zoom = initialZoombefore map creation and passingzoom: initialZoomensures mobile and tablet widths start at the intended globe view. This directly addresses the previous mismatch on small screens.
User description
The map component was not using the calculated
initialZoomfor mobile devices, causing the map to be zoomed in by default.This commit fixes the issue by:
currentMapCenterRef.current.zoomwith theinitialZoomvalue.initialZoomwhen creating themapboxgl.Mapinstance.This ensures that mobile and tablet devices get the appropriate zoom level for a full globe preview.
PR Type
Bug fix
Description
Fix mobile device map zoom initialization issue
Ensure correct initial zoom level for mobile/tablet devices
Update map center reference with calculated zoom value
Diagram Walkthrough
File Walkthrough
mapbox-map.tsx
Fix mobile map zoom initializationcomponents/map/mapbox-map.tsx
initialZoomtocurrentMapCenterRef.current.zoominitialZoomvariable in Mapconstructor
Summary by CodeRabbit