Fine tuning the behavior of the modal UI

This is a PR to address the behaviors describe in this issue: #4885