diff --git a/CHANGELOG.txt b/CHANGELOG.txt index da7ba610ff..838a88881b 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -41,6 +41,7 @@ Changelog * Fix: Prevent duplicate addition of StreamField blocks with the new block picker (Deepam Priyadarshi) * Fix: Enable partial search on images and documents index view where available (Mng) * Fix: Adopt a no-JavaScript and more accessible solution for option selection in reporting, using HTML only `radio` input fields (Mehul Aggarwal) + * Fix: Ensure that document search results count shows the correct all matches, not the paginate total (Andy Chosak) * Docs: Add code block to make it easier to understand contribution docs (Suyash Singh) * Docs: Add new "Icons" page for icons customisation and reuse across the admin interface (Coen van der Kamp) * Docs: Fix broken formatting for MultiFieldPanel / FieldRowPanel permission kwarg docs (Matt Westcott) diff --git a/docs/releases/5.0.md b/docs/releases/5.0.md index 77a59ee60b..2218d0ef90 100644 --- a/docs/releases/5.0.md +++ b/docs/releases/5.0.md @@ -55,6 +55,7 @@ Support for adding custom validation logic to StreamField blocks has been formal * Prevent duplicate addition of StreamField blocks with the new block picker (Deepam Priyadarshi) * Enable partial search on images and documents index view where available (Mng) * Adopt a no-JavaScript and more accessible solution for option selection in reporting, using HTML only `radio` input fields (Mehul Aggarwal) + * Ensure that document search results count shows the correct all matches, not the paginate total (Andy Chosak) ### Documentation diff --git a/wagtail/documents/templates/wagtaildocs/documents/results.html b/wagtail/documents/templates/wagtaildocs/documents/results.html index 1ec27422dc..ac2a3c49cf 100644 --- a/wagtail/documents/templates/wagtaildocs/documents/results.html +++ b/wagtail/documents/templates/wagtaildocs/documents/results.html @@ -2,7 +2,7 @@ {% if documents %} {% if is_searching %}

- {% blocktrans trimmed count counter=documents|length %} + {% blocktrans trimmed count counter=documents.paginator.count %} There is {{ counter }} match {% plural %} There are {{ counter }} matches diff --git a/wagtail/documents/tests/test_admin_views.py b/wagtail/documents/tests/test_admin_views.py index 6366a8d7c8..cc5c05388c 100644 --- a/wagtail/documents/tests/test_admin_views.py +++ b/wagtail/documents/tests/test_admin_views.py @@ -114,6 +114,15 @@ class TestDocumentIndexView(WagtailTestUtils, TestCase): response.context["documents"].paginator.num_pages, ) + def test_pagination_q(self): + self.make_docs() + + response = self.get({"q": "Test"}) + + self.assertEqual(response.status_code, 200) + self.assertTemplateUsed(response, "wagtaildocs/documents/index.html") + self.assertContains(response, "There are 50 matches") + def test_ordering(self): orderings = ["title", "-created_at"] for ordering in orderings: