feat(google-maps): add #renderer slot to ScriptGoogleMapsMarkerClusterer#675
feat(google-maps): add #renderer slot to ScriptGoogleMapsMarkerClusterer#675
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughAdds slot-based cluster rendering to ScriptGoogleMapsMarkerClusterer: a new Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@docs/content/scripts/google-maps/2.api/4.marker-clusterer.md`:
- Around line 100-103: Update the "Custom Cluster Renderer" docs to mention the
additional `map` slot prop: note that the renderer slot receives `cluster` (with
`count`, `position`, `markers`), `stats`, and `map`; reference the component
forwarding call `slots.renderer({ cluster, stats, map })` and the
MarkerClusterer renderer contract so consumers know `map` (the Google Map
instance) is available to renderer templates.
In
`@packages/script/src/runtime/components/GoogleMaps/ScriptGoogleMapsMarkerClusterer.vue`:
- Around line 30-33: Update the ClusterStats interface to match
`@googlemaps/markerclusterer` v2.6.2: replace the current clusters and markers
arrays with the library contract so ClusterStats has clusters: { count: number;
markers: { min: number; max: number; mean: number; sum: number } } and markers:
{ sum: number }; locate and update the ClusterStats declaration (export
interface ClusterStats) and any dependent usages expecting the old shape (e.g.,
code referencing stats.clusters or stats.markers) to the new property
names/types.
- Around line 106-109: The current render function calls slots.renderer(...) and
mounts a fresh vueRender root, which breaks provide/inject and freezes the
vnode; change it to defer calling slots.renderer until actual render by creating
a wrapper vnode whose render function invokes slots.renderer({ cluster, stats,
map }) at mount time, assign the component's appContext to that wrapper vnode
(e.g., vnode.appContext = instance.appContext or
getCurrentInstance().appContext) before calling vueRender, and remove the
precomputed vnodes variable so injected keys like MARKER_CLUSTERER_INJECTION_KEY
and MAP_INJECTION_KEY are available inside the slot.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 7759fb2e-3c29-4386-998c-27fda162eb1b
📒 Files selected for processing (4)
docs/content/scripts/google-maps/1.guides/6.marker-clustering.mddocs/content/scripts/google-maps/2.api/4.marker-clusterer.mdpackages/script/src/runtime/components/GoogleMaps/ScriptGoogleMapsMarkerClusterer.vuetest/unit/google-maps-components.test.ts
packages/script/src/runtime/components/GoogleMaps/ScriptGoogleMapsMarkerClusterer.vue
Show resolved
Hide resolved
packages/script/src/runtime/components/GoogleMaps/ScriptGoogleMapsMarkerClusterer.vue
Outdated
Show resolved
Hide resolved
- Fix ClusterStats interface to match @googlemaps/markerclusterer v2.6.2 - Propagate appContext to slot render root so provide/inject works - Defer slot invocation to render time - Document `map` slot prop
🔗 Linked issue
Resolves #674
❓ Type of change
📚 Description
Adds a
#rendererscoped slot toScriptGoogleMapsMarkerClustererthat lets users customize cluster visuals with Vue templates instead of writing imperative JS withdocument.createElement. The slot receives{ cluster, stats, map }and renders each cluster as anAdvancedMarkerElementwith the slot content as its visual.The slot name
#rendereraligns with the@googlemaps/markerclustererlibrary'srendereroption. When the slot is provided, it overrides anyrendererpassed viaoptions.