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

add menu select widget #2316

Merged
merged 11 commits into from
Sep 20, 2017
Merged

add menu select widget #2316

merged 11 commits into from
Sep 20, 2017

Conversation

iam4x
Copy link
Contributor

@iam4x iam4x commented Sep 7, 2017

Summary

Works like a menu widget but displays as a select DOM element.

  • Widget
  • Documentation
  • Example
  • Tests

Result

sep-07-2017 17-54-38

Fixes #1904

@iam4x iam4x added this to the 2.2 milestone Sep 7, 2017
@iam4x iam4x requested a review from bobylito September 7, 2017 15:57
@bobylito
Copy link
Contributor

bobylito commented Sep 7, 2017

Nice :)

@algobot
Copy link
Contributor

algobot commented Sep 7, 2017

Deploy preview ready!

Built with commit f269340

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

@algobot
Copy link
Contributor

algobot commented Sep 7, 2017

Deploy preview ready!

Built with commit 2c1ac30

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

Copy link
Contributor

@bobylito bobylito left a comment

Choose a reason for hiding this comment

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

A comment :) and a proposal of change. Good work, that's pretty cool 👍

templateProps: PropTypes.object.isRequired,
};

get selectValue() {
Copy link
Contributor

Choose a reason for hiding this comment

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

This is not very idiomatic with the rest of the codebase. Do we want to move forward with that notation?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Let's use the JavaScript features we are offered no? (When it makes sense).
I like JavaScript getters, and here it makes sense because I use this value more than once.

templateProps: PropTypes.object.isRequired,
};

get selectValue() {
Copy link
Contributor

Choose a reason for hiding this comment

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

isn't it selectedValue?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In my head it was the value of the DOM element, so selectValue. But it works the other way around also.

}

handleSelectChange = ({ target: { value } }) => {
this.props.refine(value === 'all' ? this.selectValue.value : value);
Copy link
Contributor

Choose a reason for hiding this comment

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

That's interesting. You implement a special value for the selection. I think it should be part of the connector API. I would go for undefined or null (or both) as refine(null) is semantically close to "refine nothing" which is what we want when implementing "no filter / all".

Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

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, I don't really know if it's the right time, we need to introduce this change a bit everywhere (according to the issue) like on the connectRefinementList connectHieararchicalMenu etc...

We can do this in the next step?

@@ -139,6 +139,23 @@ export default function connectMenu(renderFn) {
return this.isShowingMore ? showMoreLimit : limit;
},

refine({ helper, items }) {
return facetValue => {
Copy link
Contributor

@bobylito bobylito Sep 11, 2017

Choose a reason for hiding this comment

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

When working with @marielaures we found that actually you don't need to use items to figure out the refined value. You can get it using getHierarchicalFacetBreadcrumb (doc), the first item will be the one currently selected if any.

Using this, you can simplify the code by keeping the reference to the helper from the init call.

@bobylito bobylito removed this from the 2.2 milestone Sep 19, 2017
Copy link
Contributor

@bobylito bobylito left a comment

Choose a reason for hiding this comment

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

Nice :) We finally have this widget and you did it twice! Thanks 💯

@bobylito bobylito merged commit 077fdfa into feat/2.2 Sep 20, 2017
@iam4x
Copy link
Contributor Author

iam4x commented Sep 20, 2017

With pleasure 🙌

bobylito pushed a commit that referenced this pull request Sep 20, 2017
* feat(widgets): add menuSelect widget
* feat(dev): add example menuSelect
* doc(menu): minor fixes
* doc(menuSelect): write documentation about menuSelect widget
* feat(connectMenu): falsy values remove filter
* refactor(MenuSelect): use falsy value to remove refined value
* test(menuSelect): test widget & component
* fix(connectMenu): correctly cache returned `refine` fn
* fix(MenuSelect): templatesProps
* refactor(connectMenu): dont re-instanciate a fn at every render
* refactor(connectMenu): rename to `this._refine`
@bobylito bobylito deleted the feat/2.2-menuSelect branch September 20, 2017 14:19
@vvo
Copy link
Contributor

vvo commented Sep 21, 2017

GG this has been a long discussed widget over time since the start of IS.js. Now we just did it, because we wanted it. 💥

samouss pushed a commit that referenced this pull request Oct 2, 2017
* feat(widgets): add menuSelect widget
* feat(dev): add example menuSelect
* doc(menu): minor fixes
* doc(menuSelect): write documentation about menuSelect widget
* feat(connectMenu): falsy values remove filter
* refactor(MenuSelect): use falsy value to remove refined value
* test(menuSelect): test widget & component
* fix(connectMenu): correctly cache returned `refine` fn
* fix(MenuSelect): templatesProps
* refactor(connectMenu): dont re-instanciate a fn at every render
* refactor(connectMenu): rename to `this._refine`
samouss pushed a commit that referenced this pull request Oct 2, 2017
* feat(widgets): add menuSelect widget
* feat(dev): add example menuSelect
* doc(menu): minor fixes
* doc(menuSelect): write documentation about menuSelect widget
* feat(connectMenu): falsy values remove filter
* refactor(MenuSelect): use falsy value to remove refined value
* test(menuSelect): test widget & component
* fix(connectMenu): correctly cache returned `refine` fn
* fix(MenuSelect): templatesProps
* refactor(connectMenu): dont re-instanciate a fn at every render
* refactor(connectMenu): rename to `this._refine`
samouss pushed a commit that referenced this pull request Oct 3, 2017
* feat(widgets): add menuSelect widget
* feat(dev): add example menuSelect
* doc(menu): minor fixes
* doc(menuSelect): write documentation about menuSelect widget
* feat(connectMenu): falsy values remove filter
* refactor(MenuSelect): use falsy value to remove refined value
* test(menuSelect): test widget & component
* fix(connectMenu): correctly cache returned `refine` fn
* fix(MenuSelect): templatesProps
* refactor(connectMenu): dont re-instanciate a fn at every render
* refactor(connectMenu): rename to `this._refine`
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