Skip to content
This repository has been archived by the owner on Dec 30, 2022. It is now read-only.

Commit

Permalink
fix(localizecount): allow localized string for count in MenuSelect (#657
Browse files Browse the repository at this point in the history
)

* fix(localizecount): allow localized string for count in MenuSelect

* Removes potentially confusing example

* Avoids modifying an object inside a map
  • Loading branch information
devwax authored and samouss committed Nov 27, 2017
1 parent d473dab commit 67ebd34
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
5 changes: 4 additions & 1 deletion packages/react-instantsearch/src/components/MenuSelect.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@ class MenuSelect extends Component {
PropTypes.shape({
label: PropTypes.string.isRequired,
value: PropTypes.string.isRequired,
count: PropTypes.number.isRequired,
count: PropTypes.oneOfType([
PropTypes.number.isRequired,
PropTypes.string.isRequired,
]),
isRefined: PropTypes.bool.isRequired,
})
),
Expand Down
21 changes: 21 additions & 0 deletions stories/MenuSelect.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,4 +105,25 @@ stories
displayName,
filterProps,
}
)
.addWithJSX(
'with localized count',
() => (
<WrapWithHits linkedStoryGroup="MenuSelect">
<MenuSelect
attributeName="category"
defaultRefinement={text('defaultSelectedItem', 'Bathroom')}
transformItems={items =>
items.map(({ count, ...item }) => ({
...item,
count: (count + 1000).toLocaleString(),
}))
}
/>
</WrapWithHits>
),
{
displayName,
filterProps,
}
);

0 comments on commit 67ebd34

Please sign in to comment.