A number of things happen as the telescope's line of sight gets closer to pointing at the sun.
First will be an increase in heating on an part of the optical barrel directly exposed to sunlight (even if insulated). Depending on material and construction, this will lead to deformation that will affect the optics. As the line of sight gets even closer to the sun, light might start shining on any secondary mirror assembly at the end of the telescope. This will also heat up the secondary assembly, again causing deformation, if not actual damage. Whether this deformation is acceptable will, of course, depend on the design of the telescope and its operating parameters.
As the angle between line of sight and sun line gets smaller, reflections will start shining inside the barrel. Most telescopes, including ground based telescopes, have baffles to keep stray light for making it all the way to the mirror and ultimately the detectors. This picture of an Opticstar ground based telescope shows the baffles very clearly.
Hubble also has similar baffles, as seen in this diagram.
Note that the term "baffle" is sometimes used for the entire tube, and sometimes for the light blocking features inside the tube.
Ultimately as the telescope points closer to the sun, light will have a direct path to the primary mirror (assuming a standard Newtonian type design). The main mirror will then start focusing the light. At first the focused light will shine on the inside of the telescope tube. I once worked a program where we computed that reflected sun light from the primary unto the composite telescope tube would burn a hole in less than a few seconds. Finally, if the sun is directly aligned with the telescope, the sunshine will shine directly on the detector array possibly damaging it if it is not protected by physical means (shutter) or design (robustness).
These are all "general" statements, since every telescope design is different. Some telescopes, like James Webb operating in the infrared regime, are so sensitive to an light from the sun, that great measures are taken to protect them from any direct sunlight. Webb has a massive sunshield to keep it nice and cool. To further protect it, it will orbit in the Sun-Earth L2 point so that the earth and sun are always in the same direction as seen from the telescope.