Skip to content

davidasix/google place id lookups#13

Merged
DavidASix merged 37 commits into
mainfrom
davidasix/google-place-id-lookups
Jul 27, 2025
Merged

davidasix/google place id lookups#13
DavidASix merged 37 commits into
mainfrom
davidasix/google-place-id-lookups

Conversation

@DavidASix

Copy link
Copy Markdown
Owner

Google made this so much harder than it needs to be.

This is essentially an implementation of Google's custom component gpm-place-autocomplete, and a lot of the docs can be found here:

https://developers.google.com/maps/documentation/javascript/place-autocomplete-new#example-maps

Unfortunately it renders all its content as closed shadow DOM which cannot be relied upon for functionality.

@DavidASix
DavidASix requested a review from Copilot July 5, 2025 23:24

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull Request Overview

This PR implements a client-side Google Places autocomplete input using the new gmp-place-autocomplete custom element to capture and display a Place ID on the Google Reviews page.

  • Adds a GooglePlaceInput component that loads the Maps JS API and handles selection/clearing events.
  • Integrates GooglePlaceInput into GoogleReviewPage, storing and displaying the selected placeId.
  • Updates package.json to include @types/google.maps for TypeScript support.

Reviewed Changes

Copilot reviewed 3 out of 4 changed files in this pull request and generated 2 comments.

File Description
src/app/(product)/google-reviews/page.tsx Integrates GooglePlaceInput and renders selected Place ID UI.
src/app/(product)/google-reviews/_components/google-place-input.tsx Introduces the autocomplete component with script loading and event wiring.
package.json Adds @types/google.maps to devDependencies.
Comments suppressed due to low confidence (2)

src/app/(product)/google-reviews/_components/google-place-input.tsx:35

  • This new component lacks accompanying unit or integration tests. Consider adding tests for initializing the script, handling gmp-select events, and clearing selection to ensure reliable behavior.
export default function GooglePlaceInput({

src/app/(product)/google-reviews/_components/google-place-input.tsx:129

  • [nitpick] The loading=async query parameter is unnecessary since Next.js Script with strategy="afterInteractive" handles script loading behavior. It can be removed for clarity.
        src={`https://maps.googleapis.com/maps/api/js?key=${API_KEY}&libraries=places&loading=async`}

// If a place is currently selected and user starts typing, clear the selection
if (selectedPlaceId) {
// Small delay to let any internal clear logic execute first
setTimeout(() => {

Copilot AI Jul 5, 2025

Copy link

Choose a reason for hiding this comment

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

The setTimeout callback isn’t cleared on unmount, which could lead to state updates after the component is gone. Capture the timer ID and clear it in the effect’s cleanup.

Suggested change
setTimeout(() => {
const timerId = setTimeout(() => {

Copilot uses AI. Check for mistakes.
strategy="afterInteractive"
onLoad={() => setIsLoaded(true)}
/>
{React.createElement("gmp-place-autocomplete", {

Copilot AI Jul 5, 2025

Copy link

Choose a reason for hiding this comment

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

The placeholder prop passed into GooglePlaceInput isn’t forwarded to the underlying gmp-place-autocomplete element. Add placeholder to the props object so consumers can customize it.

Copilot uses AI. Check for mistakes.
@DavidASix DavidASix changed the title [WIP] davidasix/google place id lookups davidasix/google place id lookups Jul 6, 2025
@DavidASix
DavidASix merged commit bcb0cae into main Jul 27, 2025
2 checks passed
@DavidASix
DavidASix deleted the davidasix/google-place-id-lookups branch July 27, 2025 21:17
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.

2 participants