Skip to content

Commit

Permalink
fix: dont throw on geolocation error, add param to handler instead (#41)
Browse files Browse the repository at this point in the history
  • Loading branch information
noclat committed Nov 11, 2023
1 parent afb26a8 commit ccc682a
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ pka.on('open', () => {})
.on('dirty', (bool) => {})
.on('empty', (bool) => {})
.on('freeForm', (bool) => {})
.on('geolocation', (bool, position) => {});
.on('geolocation', (bool, position, error) => {});
.on('countryMode', (bool) => {});
.on('state', (state) => {})
.on('countryChange', (item) => {});
Expand Down Expand Up @@ -339,6 +339,7 @@ Triggered when `state.geolocation` value changes (a.k.a. when `pka.requestGeoloc
| --- | --- | --- |
| `geolocation` | `boolean` | `true` if granted, `false` if denied. |
| `position` | [`GeolocationPosition \| undefined`](https://developer.mozilla.org/en-US/docs/Web/API/GeolocationPosition) | Passed when `geolocation` is `true`. |
| `error` | [`string \| undefined`](https://developer.mozilla.org/en-US/docs/Web/API/GeolocationPosition) | Geolocation request error message. |

##### `countryMode`

Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@placekit/autocomplete-js",
"version": "2.1.3",
"version": "2.1.4",
"author": "PlaceKit <[email protected]>",
"description": "PlaceKit Autocomplete JavaScript library",
"license": "MIT",
Expand Down
3 changes: 1 addition & 2 deletions src/placekit-autocomplete.js
Original file line number Diff line number Diff line change
Expand Up @@ -623,8 +623,7 @@ export default function placekitAutocomplete(
search();
return pos;
}).catch((err) => {
setState({ geolocation: false });
throw err;
setState({ geolocation: false }, undefined, err.message);
});
};

Expand Down

0 comments on commit ccc682a

Please sign in to comment.