Somebody asked regarding getting random thoughts (wasawis) of riya (showing off).
Sayyidi wa sanadi Mufti Mohammed Taqi Usmani ( Allah preserve & protect him) replied that riya is a volitional act. It is done, it does not happen by itself.
So one should not be too worried about getting such stray random thoughts. However, there is a chance that these random thoughts may develop into actual riya. So one should remain cautious at all times and vigilantly take note of what thoughts make one happy. At the same time, one should inform Allah Ta’ala about these stray thoughts and seek His protection (i.e. do ruju ilallah).
Look! I have already told you that ruju ilallahis the key to Tareeqat! Just take this one thing with yourself! Adopt it as your way of life!”
Intekhab e Kaiseri, Ramadan 1440