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
@lucavb lucavb force-pushed the fix-permission-denied-error branch from cf5ac98 to d58ce39 Compare December 12, 2025 08:23
@lucavb lucavb force-pushed the fix-permission-denied-error branch from d58ce39 to 3072c19 Compare December 17, 2025 11:33
@lucavb lucavb force-pushed the fix-permission-denied-error branch from 3072c19 to cb44ad0 Compare December 26, 2025 19:58
…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 cb44ad0 to 762b735 Compare January 2, 2026 14:51
@github-actions
Copy link

github-actions bot commented Jan 2, 2026

Hey, @lucavb 👋 Thanks for your contribution to Mapbox GL JS!

Important: This repository does not accept direct merges. All changes go through our internal review process.

What happens next:

  1. A team member will review your PR here first
  2. If it looks good, they will import it to our internal repository for further review
  3. If approved, changes will be synced back here via our release process

Please respond to any review comments on this PR. For more details, see CONTRIBUTING.md.

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