Skip to content

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

Fix bug where price filter is not hiding when it is supposed to

dominik-zeglene7d69870bd25
diff --git a/saleor/static/js/storefront.js b/saleor/static/js/storefront.js
index 44fd2f9602..e2ab641681 100644
--- a/saleor/static/js/storefront.js
+++ b/saleor/static/js/storefront.js
@@ -405,14 +405,14 @@ $('.toggle-filter').each(function () {
$(this).find('.filter-label').on('click', () => {
if (ele.attr('aria-expanded') !== undefined) {
- ele.removeAttr('aria-expanded').find('input[type="checkbox"]').each((i, el) => {
+ ele.removeAttr('aria-expanded').find('input[type="checkbox"], input[type="number"]').each((i, el) => {
if (!el.checked) {
$(el.parentNode.parentNode).addClass('d-none');
}
});
icon.find('img').attr('src', filterArrowDown);
} else {
- ele.attr('aria-expanded', '').find('input[type="checkbox"]').each((i, el) => {
+ ele.attr('aria-expanded', '').find('input[type="checkbox"], input[type="number"]').each((i, el) => {
$(el.parentNode.parentNode).removeClass('d-none');
});
icon.find('img').attr('src', filterArrowUp);
diff --git a/templates/category/index.html b/templates/category/index.html
index d5b8404817..97fd18861f 100644
--- a/templates/category/index.html
+++ b/templates/category/index.html
@@ -108,7 +108,8 @@
{% if field.name == 'sort_by' %}
<!--Field 'sort_by' is hidden because it is rendered in header.
This is required if you want to have sorting to be kept during further filtering.-->
- <input type="hidden" name="sort_by" value="{% if request.GET.sort_by %}{{ request.GET.sort_by }}{% endif %}">
+ <input type="hidden" name="sort_by"
+ value="{% if request.GET.sort_by %}{{ request.GET.sort_by }}{% endif %}">
{% elif field.name != 'price' %}
<div class="toggle-filter">
<h3 class="filter-label">
@@ -123,7 +124,7 @@
</div>
{% endif %}
{% endfor %}
- {% for field in filter.form %}
+ {% for field in filter.form %}
{% if field.name == 'price' %}
<div class="toggle-filter product-filters__price-range">
<h3 class="filter-label">
@@ -133,11 +134,16 @@
</div>
</h3>
<div class="filter-form-field" style="display:block">
- <input id="{{ field.auto_id }}_0" name="{{ field.name }}_0" value="{% if field.value.0 %}{{ field.value.0 }}{% endif %}" type="number" min="0" class="form-control"
- placeholder="from"><span>-</span><input id="{{ field.auto_id }}_1" name="{{ field.name }}_1" value="{% if field.value.1 %}{{ field.value.1 }}{% endif %}" type="number" min="0"
- class="form-control" placeholder="to">
- <button class="btn primary" type="submit">Update</button>
+ <div>
+ <input id="{{ field.auto_id }}_0" name="{{ field.name }}_0"
+ value="{% if field.value.0 %}{{ field.value.0 }}{% endif %}" type="number" min="0"
+ class="form-control d-inline"
+ placeholder="from"><span>-</span><input id="{{ field.auto_id }}_1" name="{{ field.name }}_1"
+ value="{% if field.value.1 %}{{ field.value.1 }}{% endif %}" type="number" min="0"
+ class="form-control d-inline" placeholder="to">
+ </div>
</div>
+ <button class="btn primary" type="submit">Update</button>
</div>
{% endif %}
{% endfor %}