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

STRF-8948 Fix Sort By on Search Page #1971

Merged
merged 1 commit into from
Feb 1, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
- Cornerstone - Image Zoom Does Not Work on Internet Explorer. [#1923](https://github.com/bigcommerce/cornerstone/pull/1923)
- Fixed input placeholder color contrast according to AA standard. [#1933](https://github.com/bigcommerce/cornerstone/pull/1933)
- Bump stencil utils to 6.8.0. [#1945](https://github.com/bigcommerce/cornerstone/pull/1945)
- Bump stencil utils to 6.8.1. and removed changes from #1910 [#1945](https://github.com/bigcommerce/cornerstone/pull/1945)

## 5.0.0 (12-14-2020)
- Parse HTML entities in jsContext. [#1917](https://github.com/bigcommerce/cornerstone/pull/1917)
Expand Down
29 changes: 0 additions & 29 deletions assets/js/theme/search.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,37 +132,8 @@ export default class Search extends CatalogPage {
$($tabsCollection.get(nextTabIdx)).focus().trigger('click');
}

getUrlParameter(queryParam) {
const regex = new RegExp(`[\\?&]${queryParam}=([^&#]*)`);
const results = regex.exec(window.location.search);
return results === null ? '' : decodeURIComponent(results[1].replace(/\+/g, ' '));
}

setupSortByQuerySearchParam() {
const searchQuery = this.getUrlParameter('search_query');

if (searchQuery.length === 0) return;

const $baseInput = $('<input/>').attr('type', 'hidden');

$('[data-sort-by]').each((idx, form) => {
const $form = $(form);
$form.append(
$baseInput.clone().attr({
name: 'search_query',
value: searchQuery,
}),
$baseInput.clone().attr({
name: 'section',
value: $form.data('sort-by'),
}),
);
});
}

onReady() {
compareProducts(this.context.urls);
this.setupSortByQuerySearchParam();

const $searchForm = $('[data-advanced-search-form]');
const $categoryTreeContainer = $searchForm.find('[data-search-category-tree]');
Expand Down
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"author": "BigCommerce",
"license": "MIT",
"dependencies": {
"@bigcommerce/stencil-utils": "^6.8.0",
"@bigcommerce/stencil-utils": "^6.8.1",
"core-js": "^3.6.5",
"creditcards": "^3.0.1",
"easyzoom": "^2.5.3",
Expand Down