When assembling the modal, find prev and next

This resolves #388 by searching for the nearest tabindex in the right
direction as opposed to the previous or next one.