I'm adding a patch to add support for clearing the search input field if the option is selected in the SearchEditForm.
toggle clear search
search field

Comments

aliyakhan created an issue. See original summary.

aliyakhan’s picture

StatusFileSize
new4.75 KB
aliyakhan’s picture

Issue summary: View changes
StatusFileSize
new28.56 KB
new34.91 KB
mikemadison’s picture

Status: Active » Needs review

Applies cleanly, works with config, and seems to function overall. Nice feature!

Status: Needs review » Needs work

The last submitted patch, 2: search_api_autocomplete_add_clear_search.patch, failed testing. View results

aliyakhan’s picture

Status: Needs work » Needs review
drunken monkey’s picture

Status: Needs review » Needs work

First off, thanks a lot for posting this!

However, it’s kind of a lot of extra code for this small feature – which also isn’t really related at all to this module’s functionality, as far as I can see? I mean, you could have such a “Clear search” (or, in general, “Clear input”) button without any autocomplete functionality, too, right?
So maybe have this as a Views extension module instead (or as part of an existing one)? Or what’s your reasoning behind wanting it in this module?

Also, when the tests fail, just setting back to “Needs review” doesn’t really make sense. You should instead try to resolve the test fail – in this case, simply changing the if ($options['clear_search']) { to if (!empty($options['clear_search'])) { should do it.

yannickoo’s picture

FYI I was just creating a new merge request for #3368795: Use search form element instead of text for using input[type="search"] instead of input[type="text"]. The cool thing about that is that a clear button comes OOTB and could be hidden via CSS if people don't want that.