Skip to content

fix(hitsPerPageSelector): Issue when state did not have a hitsPerPage #450

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

Merged
merged 1 commit into from
Nov 4, 2015

Conversation

ElPicador
Copy link
Contributor

No description provided.

@vvo
Copy link
Contributor

vvo commented Nov 4, 2015

WFM, widgets should not be dependent from other widget instantiation

vvo pushed a commit that referenced this pull request Nov 4, 2015
fix(hitsPerPageSelector): Issue when state did not have a `hitsPerPage`
@vvo vvo merged commit bc76338 into algolia:develop Nov 4, 2015
@vvo vvo removed the in progress label Nov 4, 2015
@Jerska
Copy link
Member

Jerska commented Nov 4, 2015

@vvo 2fast2merge

We just talked with @ElPicador and here is the breakdown:

The hits widget has a default value on hitsPerPage, so it should almost never be undefined, and if it is, I'm fine with forcing the user to set it in options.searchParameters at initialization time to be one of these values.

To solve it in the docs, it's easy, just add searchParameters: {hitsPerPage: 6} to the init call

I'm seeing one issue with it though, if there was a specific hitsPerPage at some point that was shared in a link and the dev overrides the available options. To solve this, I think it might make sense to do a warning instead of an error, but not silently accepting undefined.

@vvo
Copy link
Contributor

vvo commented Nov 4, 2015

The hits widget has a default value on hitsPerPage, so it should almost never be undefined, and if it is, I'm fine with forcing the user to set it in options.searchParameters at initialization time to be one of these values.

It is undefined if you have not instantiated a hits widget OR if you have your own way to display the hits (custom widget). Then state.hitsPerPage is not mandatory, you may just want to use the one from the index parameters/key etc..?

That's why I added "widgets should not be dependent from other widget instantiation" which was the case here before this fix.

You should be able to instantiate the hitsPerPage widget whether or not you have a hits widget or a custom hits widget or maybe no hits widget at all at this point (because you are building the interface asynchronously etc..)

@Jerska
Copy link
Member

Jerska commented Nov 4, 2015

For me we shouldn't silently let it go, you never want to have no selected value on a hits per page selector.

And this PR works for undefined, but not for any number that isn't in the options.

@vvo
Copy link
Contributor

vvo commented Nov 4, 2015

And this PR works for undefined, but not for any number that isn't in the options.

I do not understand the issue for this one, can you give an example?

@vvo
Copy link
Contributor

vvo commented Nov 4, 2015

I fail at seeing every cases/issues here so if you have another proposition @jerskouille go for it.

@vvo
Copy link
Contributor

vvo commented Nov 4, 2015

Thanks to @jerskouille we found more issues linked to this one, will do some more changes

@ElPicador ElPicador deleted the fix/hitsPerPage branch November 4, 2015 15:06
Jerska added a commit that referenced this pull request Nov 4, 2015
Removes the dependency on hitsPerPage.
Follow-up of #450.
Jerska added a commit that referenced this pull request Nov 5, 2015
Removes the dependency on hitsPerPage.
Follow-up of #450.
Jerska added a commit that referenced this pull request Nov 5, 2015
Removes the dependency on hitsPerPage.
Follow-up of #450.
Jerska added a commit that referenced this pull request Nov 5, 2015
Removes the dependency on hitsPerPage.
Follow-up of #450.
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.

4 participants