Skip to content

Commit

Permalink
fix(range): reset the page on refine (#4760)
Browse files Browse the repository at this point in the history
fixes #4759
  • Loading branch information
Haroenv authored May 21, 2021
1 parent 142660a commit 24e3b34
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
16 changes: 16 additions & 0 deletions src/connectors/range/__tests__/connectRange-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -667,6 +667,22 @@ See documentation: https://www.algolia.com/doc/api-reference/widgets/range-input
return helper;
};

it('resets the page', () => {
const helper = createHelper();
helper.setPage(5);
const widget = connectRange(rendering)({
attribute,
});

const { refine } = widget.getWidgetRenderState(
createInitOptions({ helper })
);

refine([10, 490]);

expect(helper.state.page).toBe(0);
});

it('expect to refine when range are not set', () => {
const helper = createHelper();
const widget = connectRange(rendering)({
Expand Down
2 changes: 1 addition & 1 deletion src/connectors/range/connectRange.ts
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ const connectRange: RangeConnector = function connectRange(
);
}

return resolvedState;
return resolvedState.resetPage();
}

return null;
Expand Down

0 comments on commit 24e3b34

Please sign in to comment.