Backport of modal positioning fix