Given the technology of the time, I'm sure they had cleaning devices running about the ship all the time. We can assume that when you materialize on the transporter pad, all of the dirt on the bottom of your shoes gets sucked off (not only for dirt confinement but also bacterial cleaning). The hangar bay has a dust magnet technology built into the floor, so that when you unload cargo from the shuttles, no errant dust or debris gets tracked into the rest of the ship; then periodically the hangar deck floor gets a good scrubbing.
We can make tons of assumptions about this, because it's such a triviality that was never touched on in the shows. I wish they had at least one episode where we see a carpet cleaning 'bot roaming the corridors, or deployed in moments after a nasty spill. They wouldn't have had to do it much, just a couple of times, and then it would put this whole thing to rest. And also a line about using the bathroom like "Where's the Captain?" "He's in the head at the moment--he should be out momentarily," and then we see him step out of the Lavatory compartment located on the bridge.