diff --git a/Classes/Domain/Search/ResultSet/ResultSetReconstitutionProcessor.php b/Classes/Domain/Search/ResultSet/ResultSetReconstitutionProcessor.php index bf658bc8b7..7e17e7c70e 100644 --- a/Classes/Domain/Search/ResultSet/ResultSetReconstitutionProcessor.php +++ b/Classes/Domain/Search/ResultSet/ResultSetReconstitutionProcessor.php @@ -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); } diff --git a/Resources/Private/Partials/Result/Sorting.html b/Resources/Private/Partials/Result/Sorting.html index 0cf7fafb46..ec36b807da 100644 --- a/Resources/Private/Partials/Result/Sorting.html +++ b/Resources/Private/Partials/Result/Sorting.html @@ -14,7 +14,7 @@ -
  • +
  • {sorting.label}
  • diff --git a/Tests/Unit/Domain/Search/ResultSet/ResultSetReconstitutionProcessorTest.php b/Tests/Unit/Domain/Search/ResultSet/ResultSetReconstitutionProcessorTest.php index 0cf10b1602..03f465488b 100644 --- a/Tests/Unit/Domain/Search/ResultSet/ResultSetReconstitutionProcessorTest.php +++ b/Tests/Unit/Domain/Search/ResultSet/ResultSetReconstitutionProcessorTest.php @@ -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.'); } /**