Attachment changing page’s permalink – $post not resetting?

I call it when I render a metabox on the edit page. (

Yeah, you shouldn’t be using globals in this context – use a foreach loop instead:

function get_available_attachments( $post /* This is the post object being edited */ ) {
    $attachments = [];
    $attach_query = new WP_Query([
        'post_type'      => 'attachment',
        'post_status'    => 'inherit', // default is 'publish'
        'post_mime_type' => 'application/pdf',
        'orderby'        => 'name',
        // 'orderby'     => 'date',
        'order'          => 'DESC',
    ]);

    foreach ( $attach_query->posts as $att ) {
        $attachments[] = ( object ) [
            'mime_type' => $att->post_mime_type,
            'title'     => $att->post_title,
            'ID'        => $att->ID
        ];

    }

    return $attachments;
}