Skip to content
This repository has been archived by the owner on Feb 2, 2023. It is now read-only.

Commit

Permalink
fix(default-location): don't default to [0,0] for defaultPosition (#550)
Browse files Browse the repository at this point in the history
* fix(default-location): don't provide any default values for defaultPosition

Completely removes the default value for defaultPosition,
which means that geosearch ranking is not applied with
a possibly irrelevant [0,0] coordinate when the state is empty.
Only tries to do .join on well-formed arrays.
  • Loading branch information
JonathanMontane authored Aug 2, 2018
1 parent 30bcc30 commit 9c0056c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
7 changes: 5 additions & 2 deletions src/instantsearch/widget.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,11 @@ import places from '../places.js';
* The underlying structure for the Algolia Places instantsearch widget.
*/
class AlgoliaPlacesWidget {
constructor({ defaultPosition = [0, 0], ...placesOptions }) {
this.defaultPosition = defaultPosition.join(',');
constructor({ defaultPosition, ...placesOptions }) {
if (defaultPosition instanceof Array && defaultPosition.length === 2) {
this.defaultPosition = defaultPosition.join(',');
}

this.placesOptions = placesOptions;
}
init({ helper }) {
Expand Down
2 changes: 1 addition & 1 deletion src/instantsearch/widget.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ describe('instantsearch widget', () => {

expect(helper.getState()).toMatchObject({
insideBoundingBox: undefined,
aroundLatLng: '0,0',
aroundLatLng: undefined,
});
});

Expand Down

0 comments on commit 9c0056c

Please sign in to comment.