When trading with a villager for an item with a discounted price the trade will not go through if you have less emeralds than the original price. For example if the original price is 15, and the discounted price is 10 but you only have 10-14 emeralds, the trade will appear as though it works. However, when you click the item to put into your inventory, it pops back into the trade menu along with your emeralds. Unlike other bugs I've seen the price does appear to be correct. If you have 15 emeralds in the case above, it will only take 10 and the trade will go through
Related issues
Comments

not sure this is actually the same issue. As I noted the price displayed is actually correct, it just won't allow you to use it in certain cases
Your description seems to match the linked ticket exactly, are you sure that the price is correct? The (additional) items you gave to the villager might take some time to visually disappear.

Ah yes I see now, in my case it was taking a little while before they disappeared so I never noticed. This is indeed a duplicate
Duplicate of MC-148454