[Bug] onMouseEnter on AdvancedMarker only works when onClick is set

Open
#542 4 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
45/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
react, typescript
Domain
frontend

Research direction

Reproduce the issue with the provided AdvancedMarker TSX example, then inspect AdvancedMarker event handling and compare it with the standard Pin behavior. The fix is complete when onMouseEnter fires without requiring an onClick handler, while the existing reproduction continues to work.

Written by the indexing model from the issue text.

Description

bug
Description

Using the onMouseEnter with a AdvancedMarker is only working when the same AdvancedMarker has a onClick property set.
If I'm using the standar Pin, it works just fine.

Steps to Reproduce
<APIProvider
  apiKey={import.meta.env.VITE_API_GOOGLE_MAPS_API_KEY}
  region="BR"
  language="pt-BR"

>
  <Map
    defaultCenter={{
      lat: -15.4,
      lng: -47.4,
    }}
    defaultZoom={10}
    id="plots-list"
    mapId={import.meta.env.VITE_API_GOOGLE_MAPS_MAP_ID}
  >
    {plotLocations.map((plot) => {
      return <AdvancedMarker position={plot.location} key={plot.id} onMouseEnter={() => console.log('test')}
        onClick={() => {}}
      >
        <div>dummy component</div>
      </AdvancedMarker>
    })}
  </Map>
</APIProvider>
Environment
  • Library version: 1.2.0
  • Google maps version: weekly
  • Browser and Version: Chrome 128.0.6613.138 (Official Build) (64-bit)
  • OS: Windows 11
Logs

No response

Dominant language
TypeScript
Stars
2k
Forks
195
Avg merge
6h 26m
Merged PRs (30d)
3

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from visgl/react-google-maps

All issues in visgl/react-google-maps

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.