Skip to content

Saleor Core: the high performance, composable, headless commerce API.

Set default sorting value

Krzysztof Białogłowicz875061cdd564
diff --git a/saleor/static/js/components/CategoryPage.js b/saleor/static/js/components/CategoryPage.js
index fc290ddabf..a176d63073 100644
--- a/saleor/static/js/components/CategoryPage.js
+++ b/saleor/static/js/components/CategoryPage.js
@@ -60,9 +60,9 @@ class CategoryPage extends Component {
});
}
- setSorting = (event) => {
+ setSorting = (value) => {
this.props.relay.setVariables({
- sortBy: event.target.className
+ sortBy: value
});
}
@@ -188,7 +188,7 @@ export default Relay.createContainer(CategoryPage, {
count: floatOrNull(getVarFromQueryString('count', PAGINATE_BY)),
minPrice: floatOrNull(getVarFromQueryString('minPrice')),
maxPrice: floatOrNull(getVarFromQueryString('maxPrice')),
- sortBy: getVarFromQueryString('sortBy')
+ sortBy: getVarFromQueryString('sortBy', 'name')
},
fragments: {
category: () => Relay.QL`
diff --git a/saleor/static/js/components/SortBy.js b/saleor/static/js/components/SortBy.js
index cca1f4e5bd..53e51507b2 100644
--- a/saleor/static/js/components/SortBy.js
+++ b/saleor/static/js/components/SortBy.js
@@ -15,7 +15,8 @@ export default class sortBy extends Component {
}
setSorting = (event) => {
- this.props.setSorting(event);
+ const value = event.target.className;
+ this.props.setSorting(value);
this.changeVisibility();
}