Depends on the season and weather pretty much. In order to provide the energy that maintains the roots and feeds the bulbs the green foliage needs to increase to allow it to take advantage of available sunlight and photosynthesise at maximum efficiency. No leaves, no bulb, no crop.
They need an occasional feed and to be kept weed free. They are ready to harvest 3 or 4 weeks after the foliage turns yellow and flops over. Here is a link to advice from the RHS on growing onions - https://www.rhs.org.uk/advice/grow-your-own/vegetables/onions They also have info on spring onions and shallots.
There are also varieties of onion which can be planted as sets in autumn and which over-winter and then produce an earlier crop than spring planted sets but they are not good for long term storage so you should just grow enough to get you thru the gap between each year's summer grown onion crops.