We saw that Grievous flew out to space in Episode 3 when the windows cracked.
But why didn't Vader and his troops do the same thing at the end of Rogue One?
Science Fiction & Fantasy Stack Exchange is a question and answer site for science fiction and fantasy enthusiasts. It only takes a minute to sign up.Sign up to join this community
As has already been suggested, magnetic boots are a distinct possibility.
Another is that the hanger bay didn't actually depressurise into hard vacuum (which, incidentally is not a mutually exclusive possibility.) Energy barriers that allow solid objects to pass though but retain the atmosphere are well established in SW lore starting right from ANH. Indeed, they appear to be standard practice where hanger bays are concerned.
Yes, there's clearly quite a bit of "wind" causing his cape to flap about in an appropriately exciting and dramatic manner, but it's possible that may simply be due to the Tantive IV departing. While it was in the bay it was taking up volume. When it left, that volume would become a void and cause a pressure differential with the rest of the ship.
The natural result would be air rushing down the corridor from other parts of the ship to fill said void and re-balance the air pressure, which is more or less what we saw.
Within the Legends canon, we learn that Vader's boots have magnetised soles that will adhere him to a metal floor.
Boot soles contain a ferromagnetic core that can be activated with mouth-operated controls. The resulting electric charge generates a strong magnetic field. Similar technology is used in zero-g spacesuits that make it possible for soldiers to cling to starship hulls.
We see these used to good effect in Star Wars: Empire: Volume One: Betrayal