When you have a filtered slot, items automatically sorts the items in the way, so you can't put away the stack, what you've grabbed.
Create at least in two slots a filter in your inventory, with the same type of item.
Grab more than 1 of this stack (for example 1.5 stack)
Grab the full stack.
Try to put it away (default: q)
After the second try, it will do the job correctly, because it'll fill the "grabbed" slot until it's full, and remove the hand icon, so it'll fill up the next slot.