Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(numericSelector): make default value possible #2565

Merged
merged 6 commits into from
Nov 10, 2017
Merged

Conversation

bobylito
Copy link
Contributor

@bobylito bobylito commented Nov 9, 2017

When we created the connectNumericSelector, we made sure to support undefined as a special value to unset the filters. However because the implementations are DOM based, the value is now a string. This patch fixes that (and adds the documentation to the feature)

I also updated the example because it was super hard to maintain and didn't have much sense in terms of feature. The new example also show case the undefined value :)

@algobot
Copy link
Contributor

algobot commented Nov 9, 2017

Deploy preview ready!

Built with commit c6771b7

https://deploy-preview-2565--algolia-instantsearch.netlify.com

Copy link
Contributor

@samouss samouss left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

Just few comments.

@@ -235,4 +235,57 @@ describe('connectNumericSelector', () => {
refine = renderingParameters.refine;
});
});

it('The refine function can unselect with `undefined` and "undefined"', () => {
const rendering = sinon.stub();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Prefer usage of jest.fn, at some point we should remove sinon

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes but if I move to jest.fn, I need to do the whole file. You might say "yes exactly do it and move like that each time you encounter sinon" and I would have to agree. OK :)

@@ -20,13 +20,13 @@ export class RawSelector extends React.Component {
<select
className={this.props.cssClasses.select}
onChange={this.handleChange}
value={currentValue}
value={`${currentValue}`}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did you set them to string? If we keep value as number, it's still works. The coercion is made by the browser.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will try then. :)

Copy link
Contributor Author

@bobylito bobylito Nov 10, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh I know, I have to transform to string because of undefined...

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes you are right... Maybe at some point we should also support empty string as reset value. With it we don't need to cast number to string in the template, just provide the default value as "".

Copy link
Contributor Author

@bobylito bobylito Nov 10, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well I think undefined is the most natural move since you can completely avoid the value and I don't think we should support more than one "0" value. However we could change it to "" if you and the team think it's best.

@bobylito bobylito merged commit 31ca3d5 into develop Nov 10, 2017
@bobylito bobylito deleted the fix/2559 branch November 10, 2017 10:11
bobylito pushed a commit that referenced this pull request Nov 13, 2017
<a name=2.2.4></a>
## [2.2.4](v2.2.3...v2.2.4) (2017-11-13)

### Bug Fixes

* **numericSelector:** make default value possible ([#2565](#2565)) ([5664f98](5664f98))
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.

3 participants