Skip to content

fix(lib): suppress browser alert when geolocation permission denied#822

Merged
antontranelis merged 2 commits intomainfrom
fix/geolocation-permission-denied
Apr 18, 2026
Merged

fix(lib): suppress browser alert when geolocation permission denied#822
antontranelis merged 2 commits intomainfrom
fix/geolocation-permission-denied

Conversation

@antontranelis
Copy link
Copy Markdown
Member

Summary

When a user has disabled geolocation in their browser and logs in, they see a native browser alert like "Geolocation error: User denied Geolocation". This PR prevents that alert and skips the auto-locate attempt entirely if permission is already denied.

Changes

  • Configure `leaflet.locatecontrol` with `showPopup: false` and a no-op `onLocationError` to suppress native browser alerts. Our own `locationerror` event handler remains active.
  • Before auto-locate on login, check `navigator.permissions.query({ name: 'geolocation' })`. If `denied`, skip `lc.start()` entirely — no prompt, no alert.
  • Manual locate button clicks still work as before (just without the native alert on error).

Context

Reported by the user: screenshot showed a browser alert on Ocean Nomads map when geolocation was blocked at browser level. The previous PR (#821) fixed mobile popup bugs but didn't cover the denied-permission case.

Test plan

  • Block geolocation in browser settings → log in → no alert, no prompt
  • Block geolocation → click locate button manually → no alert (just silently fails)
  • Allow geolocation → log in → auto-locate works as before
  • Allow geolocation → click locate → prompt appears once, works normally

🤖 Generated with Claude Code

antontranelis and others added 2 commits April 18, 2026 09:33
- Configure leaflet.locatecontrol with showPopup:false and a no-op
  onLocationError to stop native browser alerts like "Geolocation
  error: User denied Geolocation"
- Check navigator.permissions before auto-locate on login; skip
  lc.start() entirely if permission is already denied, so the user
  isn't prompted or alerted during login

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Check geolocation permission before lc.start() on manual click:
  if denied, show "Location access denied. Please enable it in your
  browser settings." toast instead of silently failing
- Track manual clicks via manualClickRef so locationerror events
  only surface a toast when the user actually triggered the action
  (not during auto-locate which handles its own flow)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@antontranelis antontranelis enabled auto-merge (squash) April 18, 2026 07:58
@antontranelis antontranelis disabled auto-merge April 18, 2026 07:58
@antontranelis antontranelis merged commit cefc3af into main Apr 18, 2026
28 checks passed
@antontranelis antontranelis deleted the fix/geolocation-permission-denied branch April 18, 2026 07:58
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.

1 participant