Skip to content

fix(google-maps): prevent center reset on re-render and export clusterer types#686

Merged
harlan-zw merged 3 commits intomainfrom
fix/google-maps-center-and-types
Apr 1, 2026
Merged

fix(google-maps): prevent center reset on re-render and export clusterer types#686
harlan-zw merged 3 commits intomainfrom
fix/google-maps-center-and-types

Conversation

@harlan-zw
Copy link
Copy Markdown
Collaborator

Summary

  • Skip setCenter when lat/lng are unchanged to prevent user pan position from resetting on unrelated re-renders (defu creates new object refs)
  • Extract marker clusterer types (Cluster, ClusterStats, etc.) into a standalone file and re-export from #nuxt-scripts/types for easier user access

Test plan

  • Unit tests added for center skip logic (3 cases: unchanged coords, changed coords, LatLng function accessors)
  • All 473 existing unit tests pass
  • Manual verification with non-reactive map options

🤖 Generated with Claude Code

…rer types

Skip setCenter when lat/lng are unchanged to prevent user pan position
from resetting on unrelated re-renders (defu creates new object refs).
Extract marker clusterer types into a standalone file and re-export from
#nuxt-scripts/types for easier user access.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@vercel
Copy link
Copy Markdown
Contributor

vercel bot commented Apr 1, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
scripts-playground Ready Ready Preview, Comment Apr 1, 2026 4:18am

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new bot commented Apr 1, 2026

Open in StackBlitz

npm i https://pkg.pr.new/@nuxt/scripts@686

commit: f1500cd

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 1, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 153c3da1-f744-48e5-8523-56df2b8bbcb3

📥 Commits

Reviewing files that changed from the base of the PR and between 53daa9e and f1500cd.

📒 Files selected for processing (1)
  • packages/script/src/runtime/components/GoogleMaps/ScriptGoogleMapsMarkerClusterer.vue
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/script/src/runtime/components/GoogleMaps/ScriptGoogleMapsMarkerClusterer.vue

📝 Walkthrough

Walkthrough

This PR moves Google Maps marker-clustering TypeScript interfaces and the MARKER_CLUSTERER_INJECTION_KEY into a new types.ts module and updates related components to import or re-export those types and the injection key from that module. It adjusts the Google Maps component's mounted watcher to compare the map's current center with the resolved next center and skip calling setCenter when latitude and longitude are identical. A regression test suite was added to verify the center-watcher behavior with different coordinate representations.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately captures both main changes: preventing center reset on re-render and exporting clusterer types, matching the file modifications and objectives.
Description check ✅ Passed The description clearly relates to the changeset by explaining the two primary modifications: center reset prevention logic and marker clusterer type extraction/re-exports.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/google-maps-center-and-types

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@harlan-zw
Copy link
Copy Markdown
Collaborator Author

Code review

No issues found. Checked for bugs and CLAUDE.md compliance.

🤖 Generated with Claude Code

Re-exports from <script> don't create local bindings in <script setup>,
causing TS2304 errors. Import types locally then re-export separately.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In
`@packages/script/src/runtime/components/GoogleMaps/ScriptGoogleMapsMarkerClusterer.vue`:
- Around line 6-7: Move the import that brings in Cluster, ClusterStats,
MarkerClustererContext, MarkerClustererInstance, MarkerClustererOptions so it
appears before the import of ./useGoogleMapsResource, and ensure the import of
MARKER_CLUSTERER_INJECTION_KEY is separated from the exports by a single blank
line; specifically, reorder the import containing those type symbols and add one
blank line after the MARKER_CLUSTERER_INJECTION_KEY import so lint ordering and
spacing rules pass.
🪄 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: 4ec24956-b001-4683-b881-b0f1e4623389

📥 Commits

Reviewing files that changed from the base of the PR and between f5e4ab0 and 53daa9e.

📒 Files selected for processing (1)
  • packages/script/src/runtime/components/GoogleMaps/ScriptGoogleMapsMarkerClusterer.vue

Comment on lines +6 to +7
import type { Cluster, ClusterStats, MarkerClustererContext, MarkerClustererInstance, MarkerClustererOptions } from './types'
import { MARKER_CLUSTERER_INJECTION_KEY } from './types'
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Fix import ordering and spacing to unblock lint checks.

Line 6 should be ordered before the ./useGoogleMapsResource import, and Line 7 should be followed by a blank line before the exports on Line 8.

💡 Suggested diff
 import { getCurrentInstance, h, inject, onBeforeUnmount, provide, shallowRef, useSlots, render as vueRender, watch } from 'vue'
+import type { Cluster, ClusterStats, MarkerClustererContext, MarkerClustererInstance, MarkerClustererOptions } from './types'
+import { MARKER_CLUSTERER_INJECTION_KEY } from './types'
 import { bindGoogleMapsEvents, MAP_INJECTION_KEY, useGoogleMapsResource } from './useGoogleMapsResource'
 
 // Import types locally (needed for <script setup> scope) and re-export for backwards compat
-import type { Cluster, ClusterStats, MarkerClustererContext, MarkerClustererInstance, MarkerClustererOptions } from './types'
-import { MARKER_CLUSTERER_INJECTION_KEY } from './types'
+
 export type { Cluster, ClusterStats, MarkerClustererContext, MarkerClustererInstance, MarkerClustererOptions }
 export { MARKER_CLUSTERER_INJECTION_KEY }
🧰 Tools
🪛 ESLint

[error] 6-6: Expected "./types" (type-sibling) to come before "./useGoogleMapsResource" (value-sibling).

(perfectionist/sort-imports)


[error] 7-7: Expected 1 empty line after import statement not followed by another import.

(import/newline-after-import)

🪛 GitHub Check: lint

[failure] 7-7:
Expected 1 empty line after import statement not followed by another import


[failure] 6-6:
Expected "./types" (type-sibling) to come before "./useGoogleMapsResource" (value-sibling)

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@packages/script/src/runtime/components/GoogleMaps/ScriptGoogleMapsMarkerClusterer.vue`
around lines 6 - 7, Move the import that brings in Cluster, ClusterStats,
MarkerClustererContext, MarkerClustererInstance, MarkerClustererOptions so it
appears before the import of ./useGoogleMapsResource, and ensure the import of
MARKER_CLUSTERER_INJECTION_KEY is separated from the exports by a single blank
line; specifically, reorder the import containing those type symbols and add one
blank line after the MARKER_CLUSTERER_INJECTION_KEY import so lint ordering and
spacing rules pass.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@harlan-zw harlan-zw merged commit 6fdd533 into main Apr 1, 2026
17 checks passed
@harlan-zw harlan-zw deleted the fix/google-maps-center-and-types branch April 1, 2026 04:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant