Gutenberg: Add a required attribute to the search block so empty searches aren't submitted

Created on 13 May 2019  路  3Comments  路  Source: WordPress/gutenberg

Describe the bug

The text field in the search block should be required so that empty or placeholder results are not submitted.
This is also a long-standing issue in core. (34886) that I hope could accompany this fix.

cc @gibrown
To reproduce
Steps to reproduce the behavior:

  1. Create a post or page
  2. add a search block
  3. publish the post or page
  4. visit the post or page

Expected behavior
an error message or notice stating that I'm submitting an empty form and a search term is required.

Additional context
Comprehensive testing has been done by Pacello Group and made some recommendations; my understanding that adding the 'required' attribute to the input element alone is a great start to this.

I've tested in firefox 66 on ubuntu; IE 11 and windows 10; and chrome and win 10 that by only adding the required attribute to the input element, visual messages for the user are displayed when the user submits a search that has a no value or a placeholder value.

(filed as a CPL employee).

[Feature] Blocks

Most helpful comment

Closed with #18635

All 3 comments

+1000 yes please.

I've made a PR for this at https://github.com/WordPress/gutenberg/pull/18635 ;

Notes and details are there.

Closed with #18635

Was this page helpful?
0 / 5 - 0 ratings