I haven't tested this on any other version, but in 1.13, the mending enchant prioritizes armor over everything even when fully repaired. I can go mining with my armor fully repaired but it doesn't repair my pickax (or anything that I am holding that has mending) until I take off my armor.
Not a bug, mending randomly chooses between your main hand, offhand, and the armor slots. If the selected item is fully repaired it will add the XP to your XP bar rather than reselecting the item.
https://minecraft.gamepedia.com/Enchanting#Mending