From bc813c873698551b52c8df671cbef04b2544a744 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafael=20K=C3=A4hm?= Date: Fri, 5 Feb 2021 12:53:31 +0100 Subject: [PATCH] [BUGFIX:BP:11] Make relevance sorting option markable as active * Makes it possible to mark relevance sorting option as active. Fixes: #2541 --- .../Search/ResultSet/ResultSetReconstitutionProcessor.php | 4 ++++ Resources/Private/Partials/Result/Sorting.html | 2 +- .../Search/ResultSet/ResultSetReconstitutionProcessorTest.php | 3 ++- 3 files changed, 7 insertions(+), 2 deletions(-) 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.'); } /**