DIAGNOSIS That rocking feeling is almost always due to worn plastic tabs, either on the battery itself or inside the drill's battery port. The little plastic rails and latches wear down over hundreds of insertions.
FIX Inspect the battery first. Look at the two sliding rails on the battery—are they cracked, chipped, or look rounded off? Try that same battery on a different Ryobi ONE+ tool. If it's loose there too, the battery is the worn part. If it's snug in another tool, then the wear is inside your drill's battery port.
IF THAT DIDN'T WORK For wear inside the drill port, the fix is more involved. You can sometimes shim the connection with a thin strip of electrical tape on the battery rail to take up the slack, but the real fix is replacing the drill's battery receptacle, which requires disassembly.
HEADS UP A loose connection isn't just annoying; it can cause intermittent power loss (making the drill stutter) and arc the contacts, which creates more heat and wear. Make sure the battery release buttons are fully clicking into place when you insert it.