Fix document context menu not showing in some circumstances