simplify and remove "cancel" bug. Detect search button click