fixes #1700 clear search box if new category is selected

Fixes #1700 
Looks like a lot more changes than it is, I mainly just moved code from inside an event to a defined function that can be called elsewhere.
due to https://github.com/ScottDowne/appmaker/blob/t1700/public/designer/js/component-tray.js#L325 you can just make this `doSearch()`