Skip to content

Commit

Permalink
[BUGFIX:BP:11] Make relevance sorting option markable as active
Browse files Browse the repository at this point in the history
* Makes it possible to mark relevance sorting option as active.

Fixes: #2541
  • Loading branch information
dkd-kaehm committed May 20, 2021
1 parent da739cc commit bc813c8
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,10 @@ protected function parseSortingIntoObjects(SearchResultSet $resultSet)
$label = $cObj->stdWrap($label, $sortingOptions['label.']);
}

if ($isResetOption && !$hasSorting) {
$selected = true;
}

$sorting = $this->getObjectManager()->get(Sorting::class, $resultSet, $sortingName, $field, $direction, $label, $selected, $isResetOption);
$resultSet->addSorting($sorting);
}
Expand Down
2 changes: 1 addition & 1 deletion Resources/Private/Partials/Result/Sorting.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

<f:if condition="{sorting.isResetOption}">
<f:then>
<li>
<li class="{f:if(condition: '{sorting.selected}', then: 'active')}" >
<a href="{s:uri.sorting.removeSorting()}" class="solr-ajaxified">{sorting.label}</a>
</li>
</f:then>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1054,7 +1054,8 @@ public function returnsResultSetWithConfiguredSortingOptions()
$processor->process($searchResultSet);

$this->assertEquals(1, $searchResultSet->getSortings()->getCount(), 'No sorting was created');
$this->assertFalse($searchResultSet->getSortings()->getHasSelected(), 'Expected that no selected sorting was present');
$this->assertEquals('relevance', $searchResultSet->getSortings()->getSelected()->getName());
$this->assertTrue($searchResultSet->getSortings()->getHasSelected(), 'The sorting by "relevance/score" is active but not marked as selected.');
}

/**
Expand Down

0 comments on commit bc813c8

Please sign in to comment.