We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Search on listing views doesn't work unless the `?q=` param exists in the URL
<!--
Found a bug? Please fill out the sections below. 👍
-->

### Issue Summary

Possible regression in https://github.com/wagtail/wagtail/pull/9768

The `URLSearchParams.get()` returns `null` if the param doesn't exist, so the following code:

https://github.com/wagtail/wagtail/blob/a3f10acae17c892d843c419495e4204adb3ed991/client/src/entrypoints/admin/core.js#L270-L276

will crash during `currentQuery.trim()` when searching on the listing views (snippets, images, etc.) if the `?q=` param doesn't exist in the URL.

Might be a good time to add `required=False` in here as well:

https://github.com/wagtail/wagtail/blob/a3f10acae17c892d843c419495e4204adb3ed991/wagtail/admin/forms/search.py#L12

to remove this silly error when `q` is an empty string:

<img width="473" alt="image" src="https://user-images.githubusercontent.com/6379424/213499685-ce37c064-2635-434f-952f-e85fae4ab9af.png">

<!--
A summary of the issue.
-->

### Steps to Reproduce

1. Spin up bakerydemo
2. Open the images listing
3. Try to search


--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `wagtail/admin/forms/search.py`
Content:
```
1 from django import forms
2 from django.utils.translation import gettext as _
3 from django.utils.translation import gettext_lazy
4 
5 
6 class SearchForm(forms.Form):
7     def __init__(self, *args, **kwargs):
8         placeholder = kwargs.pop("placeholder", _("Search"))
9         super().__init__(*args, **kwargs)
10         self.fields["q"].widget.attrs = {"placeholder": placeholder}
11 
12     q = forms.CharField(label=gettext_lazy("Search term"), widget=forms.TextInput())
13
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/wagtail/admin/forms/search.py b/wagtail/admin/forms/search.py
--- a/wagtail/admin/forms/search.py
+++ b/wagtail/admin/forms/search.py
@@ -9,4 +9,8 @@
         super().__init__(*args, **kwargs)
         self.fields["q"].widget.attrs = {"placeholder": placeholder}
 
-    q = forms.CharField(label=gettext_lazy("Search term"), widget=forms.TextInput())
+    q = forms.CharField(
+        label=gettext_lazy("Search term"),
+        widget=forms.TextInput(),
+        required=False,
+    )

{"golden_diff": "diff --git a/wagtail/admin/forms/search.py b/wagtail/admin/forms/search.py\n--- a/wagtail/admin/forms/search.py\n+++ b/wagtail/admin/forms/search.py\n@@ -9,4 +9,8 @@\n         super().__init__(*args, **kwargs)\n         self.fields[\"q\"].widget.attrs = {\"placeholder\": placeholder}\n \n-    q = forms.CharField(label=gettext_lazy(\"Search term\"), widget=forms.TextInput())\n+    q = forms.CharField(\n+        label=gettext_lazy(\"Search term\"),\n+        widget=forms.TextInput(),\n+        required=False,\n+    )\n", "issue": "Search on listing views doesn't work unless the `?q=` param exists in the URL\n<!--\r\nFound a bug? Please fill out the sections below. \ud83d\udc4d\r\n-->\r\n\r\n### Issue Summary\r\n\r\nPossible regression in https://github.com/wagtail/wagtail/pull/9768\r\n\r\nThe `URLSearchParams.get()` returns `null` if the param doesn't exist, so the following code:\r\n\r\nhttps://github.com/wagtail/wagtail/blob/a3f10acae17c892d843c419495e4204adb3ed991/client/src/entrypoints/admin/core.js#L270-L276\r\n\r\nwill crash during `currentQuery.trim()` when searching on the listing views (snippets, images, etc.) if the `?q=` param doesn't exist in the URL.\r\n\r\nMight be a good time to add `required=False` in here as well:\r\n\r\nhttps://github.com/wagtail/wagtail/blob/a3f10acae17c892d843c419495e4204adb3ed991/wagtail/admin/forms/search.py#L12\r\n\r\nto remove this silly error when `q` is an empty string:\r\n\r\n<img width=\"473\" alt=\"image\" src=\"https://user-images.githubusercontent.com/6379424/213499685-ce37c064-2635-434f-952f-e85fae4ab9af.png\">\r\n\r\n<!--\r\nA summary of the issue.\r\n-->\r\n\r\n### Steps to Reproduce\r\n\r\n1. Spin up bakerydemo\r\n2. Open the images listing\r\n3. Try to search\r\n\n", "before_files": [{"content": "from django import forms\nfrom django.utils.translation import gettext as _\nfrom django.utils.translation import gettext_lazy\n\n\nclass SearchForm(forms.Form):\n    def __init__(self, *args, **kwargs):\n        placeholder = kwargs.pop(\"placeholder\", _(\"Search\"))\n        super().__init__(*args, **kwargs)\n        self.fields[\"q\"].widget.attrs = {\"placeholder\": placeholder}\n\n    q = forms.CharField(label=gettext_lazy(\"Search term\"), widget=forms.TextInput())\n", "path": "wagtail/admin/forms/search.py"}], "after_files": [{"content": "from django import forms\nfrom django.utils.translation import gettext as _\nfrom django.utils.translation import gettext_lazy\n\n\nclass SearchForm(forms.Form):\n    def __init__(self, *args, **kwargs):\n        placeholder = kwargs.pop(\"placeholder\", _(\"Search\"))\n        super().__init__(*args, **kwargs)\n        self.fields[\"q\"].widget.attrs = {\"placeholder\": placeholder}\n\n    q = forms.CharField(\n        label=gettext_lazy(\"Search term\"),\n        widget=forms.TextInput(),\n        required=False,\n    )\n", "path": "wagtail/admin/forms/search.py"}]}