Dashboard search function doesn’t work well

Your issue is with the modification to the site search. You need to restrict your filter more. To prevent it executing on the backend add a negated is_admin() condition.

add_filter( 'pre_get_posts', 'tgm_cpt_search' );
function tgm_cpt_search( $query ) {
    if ( !is_admin() && $query->is_search )
    $query->set( 'post_type', array( 'page') );
    return $query;
};

That filter is still pretty aggressive. It will run on every search on the front end, even, for example, a specialized search added by a plugin. You probably want to at least consider adding an is_main_query condition as well.