Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Product filters do not keep the previously selected color filter when the price filter is the top. #1367

Closed
anilgautamm opened this issue Oct 2, 2018 · 3 comments

Comments

@anilgautamm
Copy link

Expected behavior

Product filters should preserve filters after range selection when price filter is the top.

Actual behavior

Product filters do not keep the previously selected color filter when the price filter is the top.

Steps to reproduce the behavior

when the price filter is the top.
https://www.useloom.com/share/f3bcb360539243beb01b6488d21f9e08

@Ubersmake Ubersmake added the bug label Nov 13, 2018
@Ubersmake
Copy link
Contributor

First mentioned in #1232 (comment).

@HikeOn
Copy link

HikeOn commented Nov 22, 2018

Hi,

The issue got resolved for us after we replaced the code

onRangeSubmit(event) {
event.preventDefault();
if (!this.priceRangeValidator.areAll(nod.constants.VALID)) {
return;
}
const url = Url.parse(window.location.href);
const queryParams = decodeURI($(event.currentTarget).serialize());
urlUtils.goToUrl(Url.format({ pathname: url.pathname, search: ?${queryParams} }));
}

in faceted-search.js file with

onRangeSubmit(event) {
event.preventDefault();
if (!this.priceRangeValidator.areAll(nod.constants.VALID)) {
return;
}
const url = Url.parse(window.location.href);
const avoidSearchQuery = 'search_query=';
const urlParams = new URLSearchParams(window.location.search);
const avoidSortValue = 'sort='+ urlParams.get('sort');
let queryParams = decodeURI($(event.currentTarget).serialize());
let path = url.path;
let urlValue;
if(path.indexOf('?') !== -1){
path = path.replace(avoidSortValue,'');
queryParams = queryParams.replace(avoidSortValue,'');
if(path.indexOf(avoidSearchQuery) !== -1){
if(urlParams.get('search_query') === null){
path = path.replace(avoidSearchQuery,'');
}else{
path = path.replace(avoidSearchQuery + urlParams.get('search_query') ,'');
}
if(path.indexOf(avoidSearchQuery+'&m') !== -1 || path.indexOf('&min_price') !== -1){
path = (path.indexOf(avoidSearchQuery+'&m') !== -1) ? path.replace(avoidSearchQuery+'&min_price='+urlParams.get('min_price')+'&max_price='+urlParams.get('max_price'),'') : path.replace('&min_price='+urlParams.get('min_price')+'&max_price='+urlParams.get('max_price'),'');
}
}
urlValue = path + &${queryParams};
urlValue = urlValue.replace(/&&[]=/g,'').replace(/&&*/g,'&').replace(/?&/g,'?');
if(urlParams.get('sort') !== null){
urlValue = urlValue + '&' + avoidSortValue;
}
}else{
urlValue = Url.format({ pathname: url.pathname, search: ?${queryParams} });
}
urlUtils.goToUrl(urlValue);
}

@Ubersmake
Copy link
Contributor

This has been fixed in 3.4.1 as a part of #1471. This should be published to all stores within the next two weeks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants