From 7dceae5febef6ee6b7be46cf017720d52c5726b7 Mon Sep 17 00:00:00 2001 From: Matt Westcott Date: Thu, 7 Sep 2023 19:17:02 +0100 Subject: [PATCH] Add release note recommending the use of AutocompleteField --- docs/releases/5.1.2.md | 20 ++++++++++++++++++++ docs/releases/5.1.md | 18 ++++++++++++++++++ 2 files changed, 38 insertions(+) diff --git a/docs/releases/5.1.2.md b/docs/releases/5.1.2.md index 51371bce7a..d33aa6fc13 100644 --- a/docs/releases/5.1.2.md +++ b/docs/releases/5.1.2.md @@ -17,3 +17,23 @@ depth: 1 * Ensure sequence on `wagtailsearchpromotions_query` table is correctly set after migrating data (Jake Howard) * Change spreadsheet export headings to match listing view column headings (Christer Jensen, Sage Abdullah) * Fix numbers, booleans, and `None` from being exported as strings (Christer Jensen) + +## Upgrade considerations + +### Search within chooser interfaces requires `AutocompleteField` for full functionality + +In Wagtail 4.2, the search bar within snippet chooser interfaces (and custom choosers created via `ChooserViewSet`) returned results for partial word matches - for example, a search for "wagt" would return results containing "Wagtail" - if this was supported by the search backend in use, and at least one `AutocompleteField` was present in the model's `search_fields` definition. Otherwise, it would fall back to only matching on complete words. In Wagtail 5.0, this fallback behaviour was removed, and consequently a model with no `AutocompleteField`s in place would return no results. + +As of Wagtail 5.1.2, the fallback behaviour has been restored. Nevertheless, it is strongly recommended that you add `AutocompleteField` to your models' `search_fields` definitions, to ensure that users can receive search results continuously as they type. For example: + +```python +from wagtail.search import index +# ... other imports + +@register_snippet +class MySnippet(index.Indexed, models.Model): + search_fields = [ + index.SearchField("name"), + index.AutocompleteField("name"), + ] +``` diff --git a/docs/releases/5.1.md b/docs/releases/5.1.md index 5420ae8591..35778abeb0 100644 --- a/docs/releases/5.1.md +++ b/docs/releases/5.1.md @@ -184,6 +184,24 @@ we have made a number of improvements to snippets as part of [RFC 85: Snippets p ## Upgrade considerations - changes affecting all projects +### Search within chooser interfaces requires `AutocompleteField` for full functionality + +In Wagtail 4.2, the search bar within snippet chooser interfaces (and custom choosers created via `ChooserViewSet`) returned results for partial word matches - for example, a search for "wagt" would return results containing "Wagtail" - if this was supported by the search backend in use, and at least one `AutocompleteField` was present in the model's `search_fields` definition. Otherwise, it would fall back to only matching on complete words. In Wagtail 5.0, this fallback behaviour was removed, and consequently a model with no `AutocompleteField`s in place would return no results. + +As of Wagtail 5.1.2, the fallback behaviour has been restored. Nevertheless, it is strongly recommended that you add `AutocompleteField` to your models' `search_fields` definitions, to ensure that users can receive search results continuously as they type. For example: + +```python +from wagtail.search import index +# ... other imports + +@register_snippet +class MySnippet(index.Indexed, models.Model): + search_fields = [ + index.SearchField("name"), + index.AutocompleteField("name"), + ] +``` + ### `GroupPagePermission` now uses Django's `Permission` model The `GroupPagePermission` model that is responsible for assigning page permissions to groups now uses Django's `Permission` model instead of a custom string. This means that the `permission_type` `CharField` has been deprecated and replaced with a `permission` `ForeignKey` to the `Permission` model.