Skip to content

Conversation

@lucavb
Copy link

@lucavb lucavb commented Dec 2, 2025

Description

Addresses: #13576

Problem

In versions 3.15.0+, the GeolocateControl error event is missing code, message, PERMISSION_DENIED, POSITION_UNAVAILABLE, and TIMEOUT properties. Users only receive { target, type } instead of the full error information.

Root Cause

GeolocationPositionError is a native DOM object with non-enumerable properties. When passed directly to new Event('error', error), the Event constructor uses Object.assign() which doesn't copy non-enumerable properties.

Solution

Explicitly extract properties from GeolocationPositionError when creating the error event, matching the pattern already used for the geolocate event (fixed in commit 9a1c893).

Before:

this.fire(new Event('error', error));

After:

this.fire(new Event('error', {
    code: error.code,
    message: error.message,
    PERMISSION_DENIED: error.PERMISSION_DENIED,
    POSITION_UNAVAILABLE: error.POSITION_UNAVAILABLE,
    TIMEOUT: error.TIMEOUT
} as GeolocationPositionError));

Here is a screenshot where I tested it in Firefox
Screenshot 2025-12-02 at 11 26 57


Launch Checklist

  • Make sure the PR title is descriptive and preferably reflects the change from the user's perspective.
  • Add additional detail and context in the PR description (with screenshots/videos if there are visual changes).
  • Manually test the debug page.
  • Write tests for all new functionality and make sure the CI checks pass.
  • Document any changes to public APIs. (N/A - this restores existing documented behavior)
  • Post benchmark scores if the change could affect performance. (N/A - no performance impact)
  • Tag @mapbox/map-design-team @mapbox/static-apis if this PR includes style spec API or visual changes. (N/A)
  • Tag @mapbox/gl-native if this PR includes shader changes or needs a native port. (N/A)
  • Tag @mapbox/gl-native if this PR disables any test because it also needs to be disabled on their side. (N/A)
  • Create a ticket for gl-native to groom in the MAPSNAT JIRA queue if this PR includes shader changes or features not present in the native side or if it disables a test that's not disabled there. (N/A)

@lucavb lucavb requested a review from a team as a code owner December 2, 2025 10:28
@CLAassistant
Copy link

CLAassistant commented Dec 2, 2025

CLA assistant check
All committers have signed the CLA.

@lucavb lucavb force-pushed the fix-permission-denied-error branch 4 times, most recently from 1e82bfb to cf5ac98 Compare December 8, 2025 08:02
…ositionError properties

- Updated the error event to fire with a structured object containing code, message, and constants for PERMISSION_DENIED, POSITION_UNAVAILABLE, and TIMEOUT.
- Added a unit test to verify that these properties are correctly passed through when an error occurs.

GitOrigin-RevId: [your-rev-id]
@lucavb lucavb force-pushed the fix-permission-denied-error branch from cf5ac98 to d58ce39 Compare December 12, 2025 08:23
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