On the bike, although the battery is exposed to the sun and heat, natural ventilation occurs while riding. The battery is designed for that! However, do not leave the battery in a car or in a glazed place in direct sunlight where the heat is intense.
An electric bicycle battery will not work for safety if the temperature of the cells is higher than 60°C.