Try to fix what might have led to the act of disinhibition. Maybe the person really is hot. Casually offer to turn on the a/c and fetch a cool cotton top.
For chronic undressers, try putting clothes on backward (buttons or zippers in the back), or look online for special clothing that’s hard to remove.
Firmly explain boundaries: “No, you can’t do that.” Try to distract with another activity or by leaving the area to go to a new scene.
Explain to friends and family (or other onlookers) that it’s the disease at work. No need to feel embarrassed. Use the incident as an occasion to educate them about how dementia affects more than memory.