Skip to content

Commit

Permalink
Submit sort on change
Browse files Browse the repository at this point in the history
  • Loading branch information
ahosgood committed Jan 10, 2024
1 parent 728a2fa commit 181fe21
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
11 changes: 1 addition & 10 deletions app/templates/search/elements/sort-view.html
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,8 @@
'text': 'Title (A to Z)',
'value': 'alphabetical'
}
] if 'q' in request.args and request.args['q'] else [
{
'text': 'Date',
'value': 'date'
},
{
'text': 'Title (A to Z)',
'value': 'alphabetical'
}
],
'selected': request.args['order'] if 'order' in request.args else '',
'selected': request.args['order'] if 'order' in request.args else 'relevance',
'inline': True,
'attributes': {
'form': 'search-form'
Expand Down
13 changes: 13 additions & 0 deletions src/scripts/search.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,3 +63,16 @@ if ($searchFiltersContent) {
$searchFiltersContent,
);
}

const $sortView = document.querySelector(".etna-search-sort-view");
const $orderSelect = document.getElementById("tna-form__order");
const $searchForm = document.getElementById("search-form");
if ($sortView && $orderSelect && $searchForm) {
const $sortViewButtonGroup = $sortView.querySelector(".tna-button-group");
if ($sortViewButtonGroup) {
$sortViewButtonGroup.remove();
$orderSelect.addEventListener("change", () => {
$searchForm.submit();
});
}
}

0 comments on commit 181fe21

Please sign in to comment.