Fixed overflow calculation for dialog overlays