This may be the same issue as https://bugs.mojang.com/browse/MC-153171 (currently closed).
Initial state:
A Master Shepard villager with 'green dye' for 12
Discounted trade to 11
64 Green dye
Villager recently refreshed (audible indicator) and slept
Actions A:
Open villager trading window
click on green dye (64 green dye added to trading window)
click on emerald (53 green dye remaining in trading window)
click on green dye (25 green dye picked up)
Expected:
Only 11 dye used in trade.
Actions B:
Open villager trading window
click on green dye (64 green dye added to trading window)
shift-click on emerald (1 emerald added to inventory, 28 green dye remaining in trade window)
click on green dye (28 picked up).
Expected:
5 emeralds added to inventory (up to limit) and 9 green dye left over.
Related issues
duplicates
Comments


I managed to generate a second villager with the green dye trade and this one does not (currently) experience the problem. This villager does not have the discount of the broken villager. Edit: I gave the non-broken villager a discount by buying a painting and the villager remained non-broken.

Additional odd behavior from the broken villager:
Open villager trading window
click on green dye (64 green dye added to trading window)
click on emerald (53 green dye remaining in trading window)
drop emerald in inventory (green dye in trading window changes to 40 spontaneously)
click on green dye (40 green dye picked up)

After the broken villager's discount wore off, the villager became unbroken.
This was probably MC-151282. Should be fixed as of 1.14.4.
I also checked a couple of other trades which seem to be working normally (wool for emeralds, emeralds for carpets).