I hold Shift and press the right mouse button and drag it to auto-put all the items, but my mouse goes over into the other inventory (chest, etc.) and it won't work. Does this maybe happen because I am using version 1.16.1?
Shift + Left Click items individually is to quick-transfer. What you're describing is a feature of Inventory Tweaks, but is usually done with the Left mouse button (whatever Button 1 is assigned to).
Shift + Right Click + Drag with an item already grabbed quick-places one item per slot hovered over. Shift + Left Click + Drag does the same, but has the stacks equally spread out, with the remainder staying in hand.
There is also a known bug prior to 1.14 where in certain cases, losing focus of the window breaks all UI events in inventories until you restarted Minecraft.