fix(advanced-marker): only assign anchorLeft/anchorTop when provided - #1066
Open
simonyang08 wants to merge 1 commit into
Open
fix(advanced-marker): only assign anchorLeft/anchorTop when provided#1066simonyang08 wants to merge 1 commit into
simonyang08 wants to merge 1 commit into
Conversation
…isgl#867) When the consumer supplied only one of `anchorLeft` or `anchorTop`, `useAdvancedMarkerAnchoring` unconditionally assigned `undefined` to the other side, clobbering the default value the Google Maps JS API had set up on the AdvancedMarkerElement. Combined with `gmpDraggable = true`, the API subsequently threw `TypeError: Failed to execute 'appendChild' on 'Node': parameter 1 is not of type 'Node'` while wiring up the drag handle (issue visgl#867). The fix only assigns the property when the consumer actually provided it, leaving the unprovided side untouched. Adds a regression test that verifies the unprovided anchor side has no own property descriptor after rendering. Signed-off-by: simonyang08 <ppt5928@gmail.com>
usefulthink
approved these changes
Sep 4, 2026
usefulthink
left a comment
Collaborator
There was a problem hiding this comment.
this is actually looking good already, is there anything else you want to add?
My only comment would be that I just noticed that the fallback logic for older versions (we had our own implementation of this before the maps API added it) can now be removed since there no longer is a google maps version that doesn't support it natively.
@mrMetalWood can you have a look at that?
Besides that, I think we could already merge this.
Comment on lines
352
to
354
| // The anchorLeft and anchorTop options are available since version 3.62.9c | ||
| // With the release of 3.65 (~May 2026) there will no longer be a version | ||
| // that doesn't support it. |
Collaborator
There was a problem hiding this comment.
while we're at it, we can now remove the support for older versions without these props.
simonyang08
marked this pull request as ready for review
September 5, 2026 15:38
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #867
Summary
When the consumer supplied only one of
anchorLeftoranchorTopto<AdvancedMarker>,useAdvancedMarkerAnchoringunconditionally assignedundefinedto the other side, clobbering the default value the Google Maps JS API had set up on the underlyingAdvancedMarkerElement. Combined withgmpDraggable = true, the API subsequently threwwhile wiring up the drag handle.
The fix only assigns each property when the consumer actually provided it, leaving the unprovided side untouched.
Reproduction
Removing
anchorTopor supplying both sides avoids the crash. This matches the reporter's findings ("removing the prop doesn't cause the crash", "in a closed environment it works").Changes
src/components/advanced-marker.tsx: guard the two assignments so each runs only when the corresponding prop was provided by the consumer.src/components/__tests__/advanced-marker.test.tsx: regression test verifying the unprovided anchor side has no own-property descriptor after rendering.Test
npx jest→ 20 suites passed, 157 tests passed (plus pre-existing todos unrelated to this change).npx tsc --project tsconfig.test.json --noEmit→ exit 0.npx eslint/prettier --checkon changed files → clean.Notes for reviewer
draggable; the jest-mocks backend cannot reproduce theappendChildTypeError. The regression test therefore locks the deterministic root-cause invariant: after rendering with onlyanchorTop, the marker must not own ananchorLeftproperty (onmainthis assertion fails withvalue: undefined).mainthat same scenario writesundefined— the crash form this PR fixes — so neither version implements a reset-to-default semantic; remount if a reset is needed.src/components/3d/marker.tsx(Marker3D) has the same unconditional-assignment pattern viausePropBinding; left out of this focused fix — happy to file a follow-up.