At least with a pickaxe, you don't get repairs from mending unless you're holding the item itself
Steps to reproduce:
Get a pickaxe with mending, may happen with other tools too, but pickaxe works for sure
Do something that gains xp without holding the item with mending in your hand, for example, Killing a mob with a sword, the durability won't appear to go up at all, and durability tooltips confirm this (f3+h)
Hold the item with mending in your hand, and then gain xp, it should work as intended
This is an intended mechanic of how Mending works. Not a bug.