prevent page refresh on enter key in header seach

- resolves #3746
- add a hidden & disabled first submit input so that ‘enter’ does not trigger submit
- allow the behaviour of the actual submit button to still work as expected
- intentionally HTML only solution as it is simpler and more accessible than JS override
pull/8172/head
Riley 2022-03-14 17:15:00 +11:00 zatwierdzone przez LB (Ben Johnston)
rodzic fe658f021f
commit 074ea8c416
4 zmienionych plików z 5 dodań i 0 usunięć

Wyświetl plik

@ -25,6 +25,7 @@ Changelog
* Migrate multiple documentation pages from RST to MD (Vibhakar Solanki, LB (Ben Johnston))
* Add documentation for defining custom form validation on models used in Wagtail's `modelAdmin` (Serafeim Papastefanos)
* Update `README.md` logo to work for GitHub dark mode (Paarth Agarwal)
* Avoid an unnecessary page reload when pressing enter within the header search bar (Images, Pages, Documents) (Riley de Mestre)
* Fix: When using `simple_translations` ensure that the user is redirected to the page edit view when submitting for a single locale (Mitchel Cabuloy)
* Fix: When previewing unsaved changes to `Form` pages, ensure that all added fields are correctly shown in the preview (Joshua Munn)
* Fix: When Documents (e.g. PDFs) have been configured to be served inline via `WAGTAILDOCS_CONTENT_TYPES` & `WAGTAILDOCS_INLINE_CONTENT_TYPES` ensure that the filename is correctly set in the `Content-Disposition` header so that saving the files will use the correct filename (John-Scott Atlakson)

Wyświetl plik

@ -570,6 +570,7 @@ Contributors
* Paarth Agarwal
* Nicolas Ferrari
* Vibhakar Solanki
* Riley de Mestre
Translators
===========

Wyświetl plik

@ -50,6 +50,7 @@ The panel types `StreamFieldPanel`, `RichTextFieldPanel`, `ImageChooserPanel`, `
* Migrate multiple documentation pages from RST to MD (Vibhakar Solanki, LB (Ben Johnston))
* Add documentation for defining [custom form validation](modeladmin_custom_clean) on models used in Wagtail's `modelAdmin` (Serafeim Papastefanos)
* Update `README.md` logo to work for GitHub dark mode (Paarth Agarwal)
* Avoid an unnecessary page reload when pressing enter within the header search bar (Images, Pages, Documents) (Riley de Mestre)
### Bug fixes

Wyświetl plik

@ -29,6 +29,8 @@
{% for field in search_form %}
{% include "wagtailadmin/shared/field_as_li.html" with field=field field_classes="field-small iconfield" icon="search" %}
{% endfor %}
{% comment %}Ad an initial disabled & hidden submit button so that pressing 'enter' will not submit form. Reload not required as the content is dynamically loaded.{% endcomment %}
<li class="visuallyhidden"><input disabled type="submit" aria-hidden="true"/></li>
<li class="submit visuallyhidden"><input type="submit" value="Search" class="button" /></li>
</ul>
</form>