No, unplugging works because cables are antennas. Power cables being disconnected dramatically reduces the ability for the lightning to couple into the device
The device itself usually has shielding, capacitors, transient suppressors, etc… as well as usually designed to make a poor antenna so on it’s own it will be affected much less than when charging
Surge protectors do work, mind you - but only for weaker storms or pulses coming in from the outside power lines. Just by physically being separated from the final device they are limited in how much they can protect from direct coupling
The device itself usually has shielding, capacitors, transient suppressors, etc… as well as usually designed to make a poor antenna so on it’s own it will be affected much less than when charging
Surge protectors do work, mind you - but only for weaker storms or pulses coming in from the outside power lines. Just by physically being separated from the final device they are limited in how much they can protect from direct coupling