-
Notifications
You must be signed in to change notification settings - Fork 612
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
feat(search): ES-1192 fixed the replace helper to expand and collapse the product filters #1689
Conversation
Autotagging @bigcommerce/storefront-team @davidchin |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cc @junedkazi
@@ -3,7 +3,7 @@ | |||
<div | |||
class="accordion-navigation toggleLink {{#unless ../start_collapsed }} is-open {{/unless}}" | |||
role="button" | |||
data-collapsible="#facetedSearch-content--{{#replace '&' (hyphenate facet) }}{{/replace}}"> | |||
data-collapsible="#facetedSearch-content--{{#replace '&' (concat '&' (hyphenate facet)) }}{{/replace}}"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry I am not sure I understand what is going on here and what are we trying to do. Can you please an explanation to the description as to why were they broken in the first place. Also I am not sure I understand why we need to add concat '&'
. Can you please explain using this example Custom & Filter
. If I am reading correctly it will look something like this;
Custom & Filter
-> hyphenate Custom-&-Filter
-> concat &Custom-&-Filter
-> replace Custom-Filter
Please correct me if I am wrong.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@junedkazi replace helper, returns empty string if it doesn't find any &
in it. Thus all the standard filters are returned as empty string
. So, we fixed it by concatenating &
to all the input facets and replace them later.
Since custom filters are part of this loop, we ended up adding and removing the &
to it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Open to suggestions here but what happens is if replace
doesn't find the replacement character, it returns an empty string. So what happens is Custom Filter
becomes: 'Custom Filter'
-> hyphenate 'Custom-Filter'
-> replace ''
. The concat
forces there to be at least one replacement token, so it always exists.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It feels so hacky and for input's like this Custom & Filter
it will generate output with double dashCustom--Filter
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree, but the whole way the expand/collapse system works using css selectors also feels just as hacky to me. I'm open to suggestions here, once again.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it should no longer return empty string based on https://github.com/bigcommerce/paper-handlebars/pull/92/files
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, I figured out what the disconnect was here. We needed to use {{replace}}
with {{else}}
, which is beyond confusing. 😕
… the product filters
bffc516
to
6b06975
Compare
Executed steps above for search, filter by category, filter by brand. Looks good 💚 |
What?
Product filters are not expanded or collapsed in category listing, brand listing & search results page when product filters for SF are turned on.
Why
Currently, we are not able to expand/collapse the filters since,
replace
helper returns empty string when the input does not have the special character&
in it. Thus collapsible divs are having same id and thus its broken this feature in the product filters.In the below image, both the
data-collapsible
in the html source is same for bothCatrgory
&Brand
filters.Tickets / Documentation
Screenshots (if appropriate)
Steps:
Cornerstone-4.6.1_fix_ES-1192.zip
) uploaded in the above issuecustom field
with special character&
in it. Ex:Custom & Filter
and save the product.Images:
Other & Custom filter expanded
![image](https://user-images.githubusercontent.com/39140274/84531613-b41d1500-ac99-11ea-9dd1-672fbbbcfd9a.png)
Other collapsed and Custom expanded
![image](https://user-images.githubusercontent.com/39140274/84531729-dd3da580-ac99-11ea-85ca-056d840dedcf.png)
Both Other & Custom filters collapsed
![image](https://user-images.githubusercontent.com/39140274/84531764-e9296780-ac99-11ea-92e1-ac08e2663b9e.png)
Other Expanded again & Custom filter collapsed
![image](https://user-images.githubusercontent.com/39140274/84531805-fba3a100-ac99-11ea-807a-409cbe352be0.png)
Both Other & Custom expanded again
![image](https://user-images.githubusercontent.com/39140274/84531856-1249f800-ac9a-11ea-9296-ed5c7a33283d.png)
All the filters collapsed
![image](https://user-images.githubusercontent.com/39140274/84531926-3279b700-ac9a-11ea-855a-51825032c5d4.png)