Skip to content

Commit

Permalink
[TASK] Show result count in live search
Browse files Browse the repository at this point in the history
Showing the result count can help users to understand the quality of the
search query.

Additionally the example is changed to work out of the box.

Resolves: #100029
Releases: main
Change-Id: I8460e24af2ea86dd5cf711c9b34768628d81e1c8
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/77944
Reviewed-by: Oliver Bartsch <bo@cedev.de>
Tested-by: core-ci <typo3@b13.com>
Tested-by: Oliver Bartsch <bo@cedev.de>
Tested-by: Andreas Fernandez <a.fernandez@scripting-base.de>
Reviewed-by: Thomas Hohn <tho@gyldendal.dk>
Reviewed-by: Andreas Fernandez <a.fernandez@scripting-base.de>
  • Loading branch information
georgringer authored and o-ba committed Feb 27, 2023
1 parent b56b6e3 commit f11f577
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
Expand Up @@ -61,7 +61,8 @@ export class ItemContainer extends LitElement {
private renderGroupedResults(groupedResults: GroupedResultItems): TemplateResult {
const items = [];
for (let [type, results] of Object.entries(groupedResults)) {
items.push(html`<h6 class="livesearch-result-item-group-label">${type}</h6>`);
let countElements = results.length;
items.push(html`<h6 class="livesearch-result-item-group-label">${type} (${countElements})</h6>`);
items.push(...results.map((result: ResultItemInterface) => html`${until(
this.renderResultItem(result),
html`<typo3-backend-spinner></typo3-backend-spinner>`
Expand Down

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

Expand Up @@ -36,10 +36,14 @@ Example
namespace MyVendor\MyExtension\Search\EventListener;
use TYPO3\CMS\Backend\Routing\UriBuilder;
use TYPO3\CMS\Backend\Search\Event\ModifyResultItemInLiveSearchEvent;
use TYPO3\CMS\Backend\Search\LiveSearch\DatabaseRecordProvider;
use TYPO3\CMS\Backend\Search\LiveSearch\ResultItemAction;
use TYPO3\CMS\Core\Imaging\Icon;
use TYPO3\CMS\Core\Imaging\IconFactory;
use TYPO3\CMS\Core\Localization\LanguageService;
use TYPO3\CMS\Core\Localization\LanguageServiceFactory;
final class AddLiveSearchResultActionsListener
{
Expand Down

0 comments on commit f11f577

Please sign in to comment.