I had something similar happen. When I had two stacks of coal in my inventory, if I attempt to put the second stack in a chest, it instead moves an amount equal to the second stack from the first stack unless the first stack is smaller than the second stack, in which case it adds an amount equal to the second stack to the chest without removing anything from the inventory.