Adding to @Ray Mills answer, I'll share the relevant World Pool-Billiard Association rules that apply.
These are from the "General Rules of Pocket Billiards" (which apply to the game of 8 Ball when not overridden by specific clauses in the rules of 8 ball pool). Emphasis ours.
1. General Rules of Pocket Billiards
1.7 Balls Settling
A ball may settle slightly after it appears to have stopped, possibly due to slight imperfections in the ball or the table. Unless this causes a ball to fall into a pocket, it is considered a normal hazard of play, and the ball will not be moved back.
If a ball falls into a pocket as the result of such settling, it is restored as closely as possible to its original position. If a settling ball falls into a pocket during or just prior to a shot, and this has an effect on the shot, the referee will restore the position and the shot will be replayed. The shooter is not penalized for shooting while a ball is settling. See also 8.3 Ball Pocketed.
8. Definitions Used in the Rules
8.3 Ball Pocketed
A ball is pocketed if it comes to rest in a pocket below the playing surface or enters the ball return system.
A ball near the brink of a pocket partly supported by another ball is considered pocketed if removal of the supporting ball would cause the ball to fall into the pocket.
If a ball stops near the edge of a pocket, and remains apparently motionless for five seconds, it is not considered pocketed if it later falls into the pocket by itself. See 1.7 Balls Settling for other details. During that five second period, the referee should ensure that no other shot is taken.
An object ball that rebounds from a pocket back onto the playing surface is not a pocketed ball.
If the cue ball contacts an already pocketed ball, the cue ball will be considered pocketed whether it rebounds from the pocket or not. The referee will remove pocketed object balls from full or nearly full pockets, but it is the shooter’s responsibility to see that this duty is performed.
In your case, the 8 ball is spotted back onto (or as close as possible to) it's original position, and player B re-takes the shot. If they make the shot after the ball is spotted, they win. If they do not make the shot, player A returns to the table.