Fix misplaced selection box in some situations