Don't persist failed search terms (#5039)
If a column is defined as searchable, that is not actually searchable (like a partial) and a user filters a list using the searchbox, an Exception is thrown. Unfortunately, this errorenous search term has already been persisted to the session so on subsequent page loads, the user is presented with an Exception with no way to resolve it themselves. This PR catches any exception that happens during the search and resets any persisted search terms so that the user can continue working after a page load. The exception itself will still be thrown. To reproduce the issue this PR solves: Set a partial column in any list as searchable: true Submit a search query Hit F5
This commit is contained in:
parent
a2b835864e
commit
dc72cafcd1
|
|
@ -128,7 +128,14 @@ class Search extends WidgetBase
|
|||
* Trigger class event, merge results as viewable array
|
||||
*/
|
||||
$params = func_get_args();
|
||||
$result = $this->fireEvent('search.submit', [$params]);
|
||||
try {
|
||||
$result = $this->fireEvent('search.submit', [$params]);
|
||||
} catch (\Throwable $e) {
|
||||
// Remove the search term from the session if the search has failed.
|
||||
$this->setActiveTerm('');
|
||||
throw $e;
|
||||
}
|
||||
|
||||
if ($result && is_array($result)) {
|
||||
return call_user_func_array('array_merge', $result);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue