Express entry list block: make input fields clear automatically after search?

Permalink
I have a custom template for the express entry list block, where i have enabled search for attributes (advanced search).

After a search has been performed, i'm noticing that the input field(s) do not clear automatically after the results are displayed, but the search words keep staying in the input fields even after visiting other pages and returning that page again!

In order to get the search mask cleared, one has to delete the search words manually from the input fields.

Is there a way to make this happen automatically, right after the search has been performed? Or at least, would it be possible to provide a "Reset Search" button for that task?

okapi
 
MrKDilkington replied on at Permalink Reply
MrKDilkington
Hi okapi,

I believe what you are describing is intended. When you search for something, you get the results and the search term(s) are persisted to remind you of what you searched for (like Google search persists search terms).

After you perform a search, visit another page, then go "back", the search terms will persist. This is because of the URL query string values. If you visit the page without going back, the search terms won't be filled in.
okapi replied on at Permalink Reply
okapi
Hi Karl,

of course you're right. The problem is, i want to hide my search fields, positioned on top of the results list, by a bootstrap collapse accordion, because searching for certain criteria in this case is expected to be mainly optional, most of the time users will want to see the whole list (results without search filter mask). For those who want do a search, clicking on a button labelled "Search for..." will smoothly unhide the search input fields.

As a consequence, after the results of the user's search are displayed, he won't see the search fields any more. If he now wants to see all items of the list, he will not be aware of the fact that his search is still active, and even after refreshing the page, he still will only see the results of his previous search.

Only after having clicked the "Search for..." button again, he will see that he has to manually delete his search terms. Hopefully he will be that patient and attentive to do so.

This is certainly a bad user experience.

As a workaround i have placed a second button labeled "Reset Search" next to the "Search for..." button, which just points to the clean URL of the page - in order to reload the page without search query string.

<button type="button" class="btn btn-default" onclick="window.location.href='<?php
        $nh = Core::make('helper/navigation');
        $URL = $nh->getCollectionURL($c);
        echo $URL; ?>'"><?php echo t('Reset Search')?>
</button>

But this seems to me a quite clumsy solution...