Skip to content

Commit

Permalink
feat: reuse config index name as default sort option (#137)
Browse files Browse the repository at this point in the history
  • Loading branch information
sarahdayan committed Jul 23, 2020
1 parent da536fc commit be54236
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
14 changes: 11 additions & 3 deletions src/components/Search.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,14 @@ export function Search(props) {

const filtersAnchor = React.useRef();

const defaultSort = [
{
label: 'Featured',
value: config.index.indexName,
},
];
const sorts = defaultSort.concat(config.sorts);

React.useEffect(() => {
if (filtersAnchor.current && props.isFiltering) {
filtersAnchor.current.scrollTop = 0;
Expand Down Expand Up @@ -106,12 +114,12 @@ export function Search(props) {
</div>

<div className="uni-BodyHeader-extraOptions">
{config.sorts?.length > 0 && (
{sorts.length > 1 && (
<div className="uni-BodyHeader-sortBy">
<span className="uni-Label">Sort by</span>
<SortBy
items={config.sorts}
defaultRefinement={config.sorts[0].value}
items={sorts}
defaultRefinement={sorts[0].value}
/>
</div>
)}
Expand Down
4 changes: 0 additions & 4 deletions src/config/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,6 @@ const config = {
hitComponent: Hit,
googleAnalytics: false,
sorts: [
{
label: 'Featured',
value: 'instant_search',
},
{
label: 'Price ascending',
value: 'instant_search_price_asc',
Expand Down

0 comments on commit be54236

Please sign in to comment.