Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Fix clashing url params with product attributes
Marcin Gębala8cbcd8bbf20b
diff --git a/saleor/static/js/components/CategoryPage.js b/saleor/static/js/components/CategoryPage.jsindex 4f0322153a..e977bbb835 100644--- a/saleor/static/js/components/CategoryPage.js+++ b/saleor/static/js/components/CategoryPage.js@@ -86,12 +86,12 @@ class CategoryPage extends Component {if (priceFilters) {priceFilters.map((param, index) => {- if (index == 0 && attributesFilter == 0) {- url += '?' + param;- } else {- url += '&' + param;- }- })+ if (index == 0 && attributesFilter == 0) {+ url += '?' + param;+ } else {+ url += '&' + param;+ }+ });}if (attributesFilter.length == 0 && priceFilters.length == 0) {diff --git a/saleor/static/js/components/PriceFilter.js b/saleor/static/js/components/PriceFilter.jsindex 2217b2d67f..9b8889f52f 100644--- a/saleor/static/js/components/PriceFilter.js+++ b/saleor/static/js/components/PriceFilter.js@@ -42,7 +42,6 @@ export default class PriceFilter extends Component {let { minPrice, maxPrice } = this.state;minPrice = this.parseValue(minPrice);maxPrice = this.parseValue(maxPrice);-this.props.onFilterChanged(minPrice, maxPrice);}diff --git a/saleor/static/js/components/ProductFilters.js b/saleor/static/js/components/ProductFilters.jsindex 122d7620da..64e53e8786 100644--- a/saleor/static/js/components/ProductFilters.js+++ b/saleor/static/js/components/ProductFilters.js@@ -15,7 +15,13 @@ class ProductFilters extends Component {constructor(props) {super(props);- this.state = {};+ let initialState = {};+ props.attributes.forEach(attribute => {+ attribute.values.forEach(value => {+ initialState[this.getFilterKey(attribute.name, value.slug)] = false;+ });+ });+ this.state = initialState;}getFilterKey(attributeName, valueSlug) {@@ -36,7 +42,9 @@ class ProductFilters extends Component {toggleFilter(attributeName, valueSlug) {const key = this.getFilterKey(attributeName, valueSlug);- this.setState(Object.assign(this.state, {[key]: !this.state[key]}));+ if (key in this.state) {+ this.setState(Object.assign(this.state, {[key]: !this.state[key]}));+ }}componentDidMount() {